gimp/app/gui/palette-editor.c

1252 lines
34 KiB
C
Raw Normal View History

1997-11-25 06:05:25 +08:00
/* 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.
1997-11-25 06:05:25 +08:00
*/
#include "config.h"
#include <gtk/gtk.h>
Makefile.am configure.in added stuff for the new library below. 2001-01-23 Michael Natterer <mitch@gimp.org> * Makefile.am * configure.in * gimptool.in: added stuff for the new library below. * libgimpcolor/.cvsignore * libgimpcolor/Makefile.am * libgimpcolor/gimpcolor.h * libgimpcolor/gimpcolorspace.c * libgimpcolor/gimpcolorspace.h * libgimpcolor/gimpcolortypes.h * libgimpcolor/gimphsv.c * libgimpcolor/gimphsv.h * libgimpcolor/gimprgb.c * libgimpcolor/gimprgb.h: new shared library which both the app and plug-ins link against. The library depends only on glib. * libgimpcolor/gimpcolor.def * libgimpcolor/makefile.mingw.in * libgimpcolor/makefile.msc: added Win32 build files which definitely don't work. * libgimp/Makefile.am * libgimp/gimpcolor.[ch] * libgimp/gimpcolorspace.[ch]: removed. * libgimp/gimp.h * libgimp/gimpadaptivesupersample.c * libgimp/gimpbilinear.c * libgimp/gimppalette.c * libgimp/gimptypes.h: include the stuff from libgimpcolor. Plug-Ins don't need to include <libgimpcolor/gimpcolor.h> explicitely. LibGimp depends on libgimpcolor and thus also includes it's headers. * libgimp/gimp.def * libgimp/makefile.mingw.in: fiddled around with Win32 stuff... * app/Makefile.am: link against libgimpcolor.la * app/apptypes.h: include "libgimpcolor/gimpcolortypes.h" * app/asupsample.c * app/channels_dialog.c * app/colormap_dialog.c * app/commands.c * app/convert.c * app/devices.c * app/disp_callbacks.c * app/drawable.c * app/gimpcontext.c * app/gimpdnd.c * app/gimpimage.c * app/gimppalette.c * app/gimprc.c * app/gradient.c * app/libgimp_glue.c * app/palette.c * app/palette_import.c * app/qmask.c * app/xcf.c * app/tools/paint_core.c * app/tools/paintbrush.c * app/tools/pencil.c: include "libgimpcolor/gimpcolor.h" before all gimp includes because it's a standalone library. * plug-ins/FractalExplorer/Makefile.am * plug-ins/Lighting/Makefile.am * plug-ins/MapObject/Makefile.am * plug-ins/bmp/Makefile.am * plug-ins/common/Makefile.am * plug-ins/common/mkgen.pl * plug-ins/dbbrowser/Makefile.am * plug-ins/faxg3/Makefile.am * plug-ins/fits/Makefile.am * plug-ins/flame/Makefile.am * plug-ins/fp/Makefile.am * plug-ins/gap/Makefile.am * plug-ins/gdyntext/Makefile.am * plug-ins/gfig/Makefile.am * plug-ins/gflare/Makefile.am * plug-ins/gfli/Makefile.am * plug-ins/gimpressionist/Makefile.am * plug-ins/helpbrowser/Makefile.am * plug-ins/ifscompose/Makefile.am * plug-ins/imagemap/Makefile.am * plug-ins/maze/Makefile.am * plug-ins/mosaic/Makefile.am * plug-ins/pagecurl/Makefile.am * plug-ins/print/Makefile.am * plug-ins/rcm/Makefile.am * plug-ins/script-fu/Makefile.am * plug-ins/sel2path/Makefile.am * plug-ins/sgi/Makefile.am * plug-ins/webbrowser/Makefile.am * plug-ins/xjt/Makefile.am: add libgimpcolor.la to LDADD. * INSTALL: don't recommend to --disable-shared for development. * TODO.xml: increased some percentages, added plug-in help stuff.
2001-01-24 02:49:44 +08:00
#include "libgimpcolor/gimpcolor.h"
#include "libgimpbase/gimpbase.h"
Makefile.am configure.in added the new library below. 2001-01-24 Michael Natterer <mitch@gimp.org> * Makefile.am * configure.in * gimptool.in: added the new library below. * libgimpwidgets/Makefile.am * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.[ch] * libgimpwidgets/gimpcolorbutton.[ch] * libgimpwidgets/gimpdialog.[ch] * libgimpwidgets/gimpfileselection.[ch] * libgimpwidgets/gimphelpui.[ch] * libgimpwidgets/gimppatheditor.[ch] * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpquerybox.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch] * libgimpwidgets/gimpwidgets.[ch] * libgimpwidgets/gimpwidgets.def * libgimpwidgets/gimpwidgetstypes.h: new shared library. Currently there are some ugly dependencies into libgimp. These will be removed and go to a "libgimpglue" library which will be a library for functions which share a common interface between plug-ins and the app but have different implementations. Include "libgimp/gimpunit.h" from "libgimpwidgets/gimpwidgetstypes.h" to simulate this upcoming separation. * libgimp/Makefile.am * libgimp/gimpchainbutton.[ch] * libgimp/gimpcolorarea.[ch] * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimpfileselection.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimppixmap.[ch] * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: removed from here. * libgimp/gimpui.h * libgimp/gimpuitypes.h * libgimp/makefile.mingw.in * libgimp/makefile.msc: changed accordingly. * app/[all ui files] * app/pdb/palette_cmds.c * app/pdb/tools_cmds.c * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: #include "libgimpwidgets/gimpwidgets.h" and removed useless includes. * app/apptypes.h: #include "libgimpwidgets/gimpwidgetstypes.h" * app/Makefile.am * plug-ins/[all makefiles which link against libgimpui]: link against libgimpwidgets.la * po-libgimp/POTFILES.in: changed file locations.
2001-01-25 06:36:18 +08:00
#include "libgimpwidgets/gimpwidgets.h"
#include "apptypes.h"
#include "widgets/widgets-types.h"
app/core/Makefile.am app/core/core-types.h added an "application object" 2001-07-04 Michael Natterer <mitch@gimp.org> * app/core/Makefile.am * app/core/core-types.h * app/core/gimp.[ch]: added an "application object" called Gimp. Currently, it contains the image list, the clipboard, the data factories, the procedural hashtable and the tool info list. It's the toplevel object of the core object system. Finally, creating a Gimp object will return a standalone gimp core engine instance with no other global states/variables involved. * app/app_procs.[ch]: allocate a "Gimp" instance called "the_gimp" :) Removed stuff which is now done by the "Gimp" object. Merged gimp_init() into app_init() because gimp_init() is taken now. * app/context_manager.[ch]: removed stuff done by "Gimp". * app/batch.[ch] * app/gimage.[ch] * app/xcf/xcf-load.[ch] * app/xcf/xcf.[ch] * app/core/gimpedit.[ch] * app/tools/tool_manager.[ch]: pass around an additional "Gimp" argument. * app/pdb/procedural_db.[ch]: pass a "Gimp" pointer as first parameter to all internal procedures and to all procedural_db_* functions. * app/core/gimpcontext.[ch] * app/core/gimpimage.[ch]: added a "Gimp" pointer to the structs. * app/devices.c * app/errors.c * app/file-open.c * app/file-save.c * app/gimphelp.c * app/gimpunit.c * app/image_new.c * app/main.c * app/nav_window.c * app/plug_in.c * app/base/base.c * app/core/gimpdatafactory.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-mask.c * app/core/gimptoolinfo.[ch] * app/gui/brush-select.c * app/gui/convert-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/gradient-select.c * app/gui/gui.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/menus.c * app/gui/palette-editor.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/paths-dialog.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/test-commands.c * app/gui/toolbox.c * app/gui/tools-commands.c * app/tools/gimpbezierselecttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimppainttool.h * app/tools/gimptexttool.c * app/tools/gimptransformtool.h * app/widgets/gimpbufferview.c * app/widgets/gimpcontainerview-utils.c * app/widgets/gimpcursor.c * app/widgets/gimpdnd.c * app/widgets/gimpimagedock.c: changed accordingly. Cleaned up lots of includes. Many files still access the global "the_gimp" variable exported by app_procs.h. * tools/pdbgen/app.pl * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/procedural_db.pdb: changed accordingly. Don't use "the_gimp" here because all procedures get passed a "Gimp" pointer now. * app/pdb/*: regenerated.
2001-07-05 03:31:35 +08:00
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpdatafactory.h"
#include "core/gimppalette.h"
2001-04-11 09:13:53 +08:00
#include "widgets/gimpcontainerlistview.h"
#include "widgets/gimpdatafactoryview.h"
#include "widgets/gimpdnd.h"
2001-04-11 09:13:53 +08:00
#include "widgets/gimppreview.h"
app/Makefile.am app/gui/Makefile.am app/about_dialog.[ch] 2001-04-17 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gui/Makefile.am * app/about_dialog.[ch] * app/brush_edit.[ch] * app/brush_select.[ch] * app/channels_dialog.[ch] * app/color_area.[ch] * app/color_notebook.[ch] * app/color_select.[ch] * app/colormap_dialog.[ch] * app/commands.[ch] * app/file_new_dialog.[ch] * app/gradient_editor.[ch] * app/gradient_select.[ch] * app/indicator_area.[ch] * app/info_dialog.[ch] * app/info_window.[ch] * app/layer_select.[ch] * app/layers_dialog.[ch] * app/menus.[ch] * app/palette.[ch] * app/palette_import.[ch] * app/palette_select.[ch] * app/paths_dialog.[ch] * app/pattern_select.[ch] * app/preferences_dialog.[ch] * app/session.[ch] * app/test_commands.[ch] * app/tips_dialog.[ch] * app/toolbox.[ch]: moved to gui/ (s/_/-/ and some more useful filenames on the way). * app/app_procs.c * app/context_manager.c * app/convert.c * app/disp_callbacks.c * app/errorconsole.c * app/file-open.c * app/file-save.c * app/file-utils.c * app/gdisplay.c * app/gimage.c * app/gimprc.c * app/image_new.c * app/interface.c * app/nav_window.c * app/path.c * app/plug_in.c * app/gui/dialogs-constructors.c * app/pdb/brush_select_cmds.c * app/pdb/convert_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/pattern_select_cmds.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpscaletool.c * app/tools/gimptransformtool.c * app/widgets/gimpcolorpanel.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/pattern_select.pdb * po/POTFILES.in: changed accordingly.
2001-04-18 05:43:29 +08:00
#include "color-area.h"
#include "color-notebook.h"
#include "palette-editor.h"
#include "palette-select.h"
1997-11-25 06:05:25 +08:00
#include "gimprc.h"
#include "libgimp/gimpintl.h"
#include "pixmaps/zoom_in.xpm"
#include "pixmaps/zoom_out.xpm"
Add default to Cancel button, remove unset GTK_RECEIVES_DEFAULT from Sat Feb 20 16:12:33 CST 1999 Shawn T. Amundson <amundson@gimp.org> * app/tips_dialog.c: Add default to Cancel button, remove unset GTK_RECEIVES_DEFAULT from prev/next buttons (they are like toolbar buttons), changed abreviated prev to previous, prev/next button are now same size, cancel button is in a button box. Added vboxes where necessary to prevent prev/next and check button from filling vertically. * app/app_procs.c: when splashscreen dialog is larger than the logo, (due to huge font), center logo. * app/file_new_dialog.c: patch from Marco Lamb <lm@geocities.com> disallows resizing, changes vertical expanding of widgets to not occur * app/palette.c: patch from Marco Lamb <lm@geocities.com>. Makes +/- buttons for zoom pixmaps (eventually, these can be replaced with a magnifying glass with a little +/- I think), so that they no longer expand as they did before. I modified his patch so it did not create a misused toolbar. I did some other stuff here too, moved Close button to the left, made it the window's default, and unset GTK_RECEIVES_DEFAULT off of the non-bottom buttons. * app/actionarea.c: another patch from Marco Lamb <lm@geocities.com>. This one changes buttons to be put in a button box which is right justified. If we decide later that spread is better, we can change this easy enough. * app/tools/zoom_in.xpm, app/tools/zoom_out.xpm: + and - graphics. * libgimp/gimpunit.h libgimp/gimpunit.c: New files from Michael Natterer <mitschel@cs.tu-berlin.de>, gimp_unit_* routines. * app/gimage.h app/gimpimage.h app/gimpimage.c app/gimpimageP.h app/xcf.c: Patches from Michael Natterer <mitschel@cs.tu-berlin.de>, which keep a unit assocated with an image.
1999-02-21 10:08:15 +08:00
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
#define ENTRY_WIDTH 12
#define ENTRY_HEIGHT 10
#define SPACING 1
#define COLUMNS 16
#define ROWS 11
1997-11-25 06:05:25 +08:00
#define PREVIEW_WIDTH ((ENTRY_WIDTH * COLUMNS) + (SPACING * (COLUMNS + 1)))
#define PREVIEW_HEIGHT ((ENTRY_HEIGHT * ROWS) + (SPACING * (ROWS + 1)))
1997-11-25 06:05:25 +08:00
#define PALETTE_EVENT_MASK (GDK_EXPOSURE_MASK | \
GDK_BUTTON_PRESS_MASK | \
GDK_ENTER_NOTIFY_MASK)
1997-11-25 06:05:25 +08:00
struct _PaletteEditor
{
GtkWidget *shell;
GtkWidget *name;
GtkWidget *color_area;
GtkWidget *scrolled_window;
GtkWidget *color_name;
GimpContext *context;
GtkWidget *popup_menu;
GtkWidget *delete_menu_item;
GtkWidget *edit_menu_item;
ColorNotebook *color_notebook;
gboolean color_notebook_active;
GimpPaletteEntry *color;
GimpPaletteEntry *dnd_color;
guint entry_sig_id;
gfloat zoom_factor; /* range from 0.1 to 4.0 */
gint col_width;
gint last_width;
gint columns;
gboolean freeze_update;
gboolean columns_valid;
GQuark invalidate_preview_handler_id;
1997-11-25 06:05:25 +08:00
};
1999-10-27 02:27:27 +08:00
/* local function prototypes */
static void palette_editor_name_activate (GtkWidget *widget,
PaletteEditor *palette_editor);
static void palette_editor_name_focus_out (GtkWidget *widget,
GdkEvent *event,
PaletteEditor *palette_editor);
static void palette_editor_create_popup_menu (PaletteEditor *palette_editor);
static void palette_editor_new_entry_callback (GtkWidget *widget,
gpointer data);
static void palette_editor_edit_entry_callback (GtkWidget *widget,
gpointer data);
static void palette_editor_delete_entry_callback (GtkWidget *widget,
gpointer data);
static void palette_editor_color_notebook_callback (ColorNotebook *color_notebook,
const GimpRGB *color,
ColorNotebookState state,
gpointer data);
static gint palette_editor_eventbox_button_press (GtkWidget *widget,
GdkEventButton *bevent,
PaletteEditor *palette_editor);
static gint palette_editor_color_area_events (GtkWidget *widget,
GdkEvent *event,
PaletteEditor *palette_editor);
static void palette_editor_draw_entries (PaletteEditor *palette,
gint row_start,
gint column_highlight);
static void palette_editor_redraw (PaletteEditor *palette_editor);
static void palette_editor_scroll_top_left (PaletteEditor *palette_editor);
static void palette_editor_color_name_changed (GtkWidget *widget,
gpointer data);
static void palette_editor_zoomin_callback (GtkWidget *widget,
gpointer data);
static void palette_editor_zoomout_callback (GtkWidget *widget,
gpointer data);
static void palette_editor_redraw_zoom (PaletteEditor *palette_editor);
static void palette_editor_close_callback (GtkWidget *widget,
gpointer data);
static void palette_editor_palette_changed (GimpContext *context,
GimpPalette *palette,
gpointer data);
static void palette_editor_drag_color (GtkWidget *widget,
GimpRGB *color,
gpointer data);
static void palette_editor_drop_color (GtkWidget *widget,
const GimpRGB *color,
gpointer data);
static void palette_editor_drop_palette (GtkWidget *widget,
GimpViewable *viewable,
gpointer data);
static void palette_editor_invalidate_preview (GimpPalette *palette,
PaletteEditor *palette_editor);
1999-10-27 02:27:27 +08:00
1997-11-25 06:05:25 +08:00
/* dnd stuff */
static GtkTargetEntry color_palette_target_table[] =
{
GIMP_TARGET_COLOR,
GIMP_TARGET_PALETTE
};
static guint n_color_palette_targets = (sizeof (color_palette_target_table) /
sizeof (color_palette_target_table[0]));
1997-11-25 06:05:25 +08:00
1999-10-27 02:27:27 +08:00
/* called from color_picker.h *********************************************/
void
palette_set_active_color (gint r,
gint g,
gint b,
gint state)
{
set style properties for dockables. 2001-08-03 Michael Natterer <mitch@gimp.org> * gtkrc: set style properties for dockables. * app/main.c: some #if 0'ed code for mem profiling. * app/gui/commands.[ch] * app/gui/menus.c: added a mem profiling menu entry + callback. * app/gui/palette-editor.c: added a #warning as reminder, use gtk_dialog_set_has_separator(). * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpcontainerview.[ch] * app/widgets/gimpdockable.[ch] * app/widgets/gimpdrawablelistview.[ch]: added some style properties to set GimpDockable and friends' borders and spacings. * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch]: GObject stuff, cleanup. * app/docindex.c * app/errorconsole.c * app/gdisplay_color_ui.c * app/gimpprogress.c * app/module_db.c * app/undo_history.c * app/user_install.c * app/gui/channels-commands.c * app/gui/gradient-editor.c * app/gui/info-window.c * app/gui/tips-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpposterizetool.c * app/tools/gimpthresholdtool.c * app/widgets/gimpdatafactoryview.c * libgimp/gimpexport.c * modules/cdisplay_gamma.c * modules/cdisplay_highcontrast.c * plug-ins/[lots of files]: Some perl mass processing applying s/_("Foo")/GTK_STOCK_FOO/g, minor manual cleanup in some files.
2001-08-04 03:43:19 +08:00
#ifdef __GNUC__
#warning FIXME: palette_set_active_color()
#endif
#if 0
GimpPalette *palette;
GimpRGB color;
gimp_rgba_set_uchar (&color,
(guchar) r,
(guchar) g,
(guchar) b,
255);
if (top_level_edit_palette)
1999-10-27 02:27:27 +08:00
{
palette = gimp_context_get_palette (top_level_edit_palette->context);
if (palette)
{
switch (state)
{
case COLOR_NEW:
top_level_edit_palette->color = gimp_palette_add_entry (palette,
NULL,
&color);
break;
case COLOR_UPDATE_NEW:
top_level_edit_palette->color->color = color;
gimp_data_dirty (GIMP_DATA (palette));
break;
default:
break;
}
}
}
1999-10-27 02:27:27 +08:00
if (active_color == FOREGROUND)
app/Makefile.am removed. 2001-07-07 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/context_manager.[ch]: removed. * app/app_procs.c: call tool_mananger instead of context_manager functions, pass "the_gimp" to some more functions. * app/drawable.[ch]: pass a GimpContext to drawable_fill(). * app/errors.c: behave according to "stack_trace_mode" when using the debugging signal handler. * app/gimprc.[ch]: removed the core/ config variables. * app/selection.c: set the selection's state to INVISIBLE in selection_pause(). * app/core/Makefile.am * app/core/gimpcoreconfig.[ch]: new files (the configuration variables used by core/). * app/core/gimpcontext.[ch]: removed the global contexts (user, default, ...) and their functions. It's no longer possible to pass NULL to the context functions to manipulate the current context (gimpcontext.c doesn't know the current context any more). * app/core/gimp.[ch]: added them here. The functions are now called gimp_[set|get]_*_context(). Added gimp_create_context() which is the only function to create contexts now. * app/gui/dialogs.[ch] * app/gui/gui.[ch]: pass "gimp" to all functions. * app/tools/tool_manager.[ch] * app/tools/tools.[ch]: pass "gimp" to lots of functions. Added the "global_tool_context" logic and the global/non-global paint options switching from the context_manager. Pass "gimp" to all tools' "register" functions. * app/tools/*: changed accordingly. * app/devices.c * app/disp_callbacks.c * app/file-open.[ch] * app/file-save.c * app/gdisplay.c * app/gimage.c * app/libgimp_glue.c * app/module_db.c * app/nav_window.c * app/plug_in.c * app/qmask.c * app/undo.c * app/base/base-config.c * app/core/gimpbrushpipe.c * app/core/gimpdrawable-offset.c * app/core/gimpgradient.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-mask.c * app/core/gimpimage-new.c * app/core/gimpimage.c * app/core/gimppalette.c * app/core/gimptoolinfo.[ch] * app/core/gimpundo.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-area.c * app/gui/dialogs-constructors.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/gradient-editor.c * app/gui/gradient-select.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/menus.c * app/gui/palette-editor.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/paths-dialog.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/resize-dialog.c * app/gui/test-commands.c * app/gui/tool-options-dialog.c * app/gui/toolbox.c * app/gui/tools-commands.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * app/widgets/gimpchannellistview.c * app/widgets/gimpdnd.c * app/widgets/gimpdrawablelistview.[ch] * app/widgets/gimpimagedock.c * app/widgets/gimplayerlistview.c * app/pdb/brushes_cmds.c * app/pdb/drawable_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/gradients_cmds.c * app/pdb/palette_cmds.c * app/pdb/patterns_cmds.c * app/pdb/procedural_db.c * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/patterns.pdb: changed accordingly: remove usage of gimp_context_[get|set]_*(NULL), create contexts with gimp_create_context(). Get the user/current context with gimp_get_[user|current]_context(). Added/removed access to the global "the_gimp" variable in some places. Get the core's config variables from "core_config".
2001-07-07 20:17:23 +08:00
gimp_context_set_foreground (gimp_get_user_context (the_gimp), &color);
1999-10-27 02:27:27 +08:00
else if (active_color == BACKGROUND)
app/Makefile.am removed. 2001-07-07 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/context_manager.[ch]: removed. * app/app_procs.c: call tool_mananger instead of context_manager functions, pass "the_gimp" to some more functions. * app/drawable.[ch]: pass a GimpContext to drawable_fill(). * app/errors.c: behave according to "stack_trace_mode" when using the debugging signal handler. * app/gimprc.[ch]: removed the core/ config variables. * app/selection.c: set the selection's state to INVISIBLE in selection_pause(). * app/core/Makefile.am * app/core/gimpcoreconfig.[ch]: new files (the configuration variables used by core/). * app/core/gimpcontext.[ch]: removed the global contexts (user, default, ...) and their functions. It's no longer possible to pass NULL to the context functions to manipulate the current context (gimpcontext.c doesn't know the current context any more). * app/core/gimp.[ch]: added them here. The functions are now called gimp_[set|get]_*_context(). Added gimp_create_context() which is the only function to create contexts now. * app/gui/dialogs.[ch] * app/gui/gui.[ch]: pass "gimp" to all functions. * app/tools/tool_manager.[ch] * app/tools/tools.[ch]: pass "gimp" to lots of functions. Added the "global_tool_context" logic and the global/non-global paint options switching from the context_manager. Pass "gimp" to all tools' "register" functions. * app/tools/*: changed accordingly. * app/devices.c * app/disp_callbacks.c * app/file-open.[ch] * app/file-save.c * app/gdisplay.c * app/gimage.c * app/libgimp_glue.c * app/module_db.c * app/nav_window.c * app/plug_in.c * app/qmask.c * app/undo.c * app/base/base-config.c * app/core/gimpbrushpipe.c * app/core/gimpdrawable-offset.c * app/core/gimpgradient.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-mask.c * app/core/gimpimage-new.c * app/core/gimpimage.c * app/core/gimppalette.c * app/core/gimptoolinfo.[ch] * app/core/gimpundo.c * app/gui/brush-select.c * app/gui/channels-commands.c * app/gui/color-area.c * app/gui/dialogs-constructors.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/gradient-editor.c * app/gui/gradient-select.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/menus.c * app/gui/palette-editor.c * app/gui/palette-import-dialog.c * app/gui/palette-select.c * app/gui/paths-dialog.c * app/gui/pattern-select.c * app/gui/preferences-dialog.c * app/gui/resize-dialog.c * app/gui/test-commands.c * app/gui/tool-options-dialog.c * app/gui/toolbox.c * app/gui/tools-commands.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * app/widgets/gimpchannellistview.c * app/widgets/gimpdnd.c * app/widgets/gimpdrawablelistview.[ch] * app/widgets/gimpimagedock.c * app/widgets/gimplayerlistview.c * app/pdb/brushes_cmds.c * app/pdb/drawable_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/gradients_cmds.c * app/pdb/palette_cmds.c * app/pdb/patterns_cmds.c * app/pdb/procedural_db.c * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/patterns.pdb: changed accordingly: remove usage of gimp_context_[get|set]_*(NULL), create contexts with gimp_create_context(). Get the user/current context with gimp_get_[user|current]_context(). Added/removed access to the global "the_gimp" variable in some places. Get the core's config variables from "core_config".
2001-07-07 20:17:23 +08:00
gimp_context_set_background (gimp_get_user_context (the_gimp), &color);
set style properties for dockables. 2001-08-03 Michael Natterer <mitch@gimp.org> * gtkrc: set style properties for dockables. * app/main.c: some #if 0'ed code for mem profiling. * app/gui/commands.[ch] * app/gui/menus.c: added a mem profiling menu entry + callback. * app/gui/palette-editor.c: added a #warning as reminder, use gtk_dialog_set_has_separator(). * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpcontainerview.[ch] * app/widgets/gimpdockable.[ch] * app/widgets/gimpdrawablelistview.[ch]: added some style properties to set GimpDockable and friends' borders and spacings. * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch]: GObject stuff, cleanup. * app/docindex.c * app/errorconsole.c * app/gdisplay_color_ui.c * app/gimpprogress.c * app/module_db.c * app/undo_history.c * app/user_install.c * app/gui/channels-commands.c * app/gui/gradient-editor.c * app/gui/info-window.c * app/gui/tips-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpposterizetool.c * app/tools/gimpthresholdtool.c * app/widgets/gimpdatafactoryview.c * libgimp/gimpexport.c * modules/cdisplay_gamma.c * modules/cdisplay_highcontrast.c * plug-ins/[lots of files]: Some perl mass processing applying s/_("Foo")/GTK_STOCK_FOO/g, minor manual cleanup in some files.
2001-08-04 03:43:19 +08:00
#endif
1999-10-27 02:27:27 +08:00
}
1997-11-25 06:05:25 +08:00
1999-10-27 02:27:27 +08:00
/* called from palette_select.c ********************************************/
void
palette_editor_set_palette (PaletteEditor *palette_editor,
GimpPalette *palette)
1999-10-27 02:27:27 +08:00
{
g_return_if_fail (palette_editor != NULL);
g_return_if_fail (GIMP_IS_PALETTE (palette));
1997-11-25 06:05:25 +08:00
gimp_context_set_palette (palette_editor->context, palette);
1997-11-25 06:05:25 +08:00
}
/* the palette & palette edit dialog constructor ***************************/
PaletteEditor *
palette_editor_new (Gimp *gimp)
{
PaletteEditor *palette_editor;
GtkWidget *main_vbox;
GtkWidget *hbox;
GtkWidget *scrolledwindow;
GtkWidget *palette_region;
GtkWidget *entry;
GtkWidget *eventbox;
GtkWidget *alignment;
GtkWidget *button;
palette_editor = g_new0 (PaletteEditor, 1);
1999-10-27 02:27:27 +08:00
palette_editor->context = gimp_create_context (gimp, NULL, NULL);
1997-11-25 06:05:25 +08:00
palette_editor->zoom_factor = 1.0;
palette_editor->columns = COLUMNS;
palette_editor->columns_valid = TRUE;
palette_editor->freeze_update = FALSE;
1999-10-27 02:27:27 +08:00
palette_editor->shell =
gimp_dialog_new (_("Palette Editor"), "palette_editor",
gimp_standard_help_func,
"dialogs/palette_editor/palette_editor.html",
GTK_WIN_POS_NONE,
FALSE, TRUE, FALSE,
1999-10-27 02:27:27 +08:00
"_delete_event_", palette_editor_close_callback,
palette_editor, NULL, NULL, TRUE, TRUE,
1997-11-25 06:05:25 +08:00
NULL);
set style properties for dockables. 2001-08-03 Michael Natterer <mitch@gimp.org> * gtkrc: set style properties for dockables. * app/main.c: some #if 0'ed code for mem profiling. * app/gui/commands.[ch] * app/gui/menus.c: added a mem profiling menu entry + callback. * app/gui/palette-editor.c: added a #warning as reminder, use gtk_dialog_set_has_separator(). * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpcontainerview.[ch] * app/widgets/gimpdockable.[ch] * app/widgets/gimpdrawablelistview.[ch]: added some style properties to set GimpDockable and friends' borders and spacings. * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch]: GObject stuff, cleanup. * app/docindex.c * app/errorconsole.c * app/gdisplay_color_ui.c * app/gimpprogress.c * app/module_db.c * app/undo_history.c * app/user_install.c * app/gui/channels-commands.c * app/gui/gradient-editor.c * app/gui/info-window.c * app/gui/tips-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpposterizetool.c * app/tools/gimpthresholdtool.c * app/widgets/gimpdatafactoryview.c * libgimp/gimpexport.c * modules/cdisplay_gamma.c * modules/cdisplay_highcontrast.c * plug-ins/[lots of files]: Some perl mass processing applying s/_("Foo")/GTK_STOCK_FOO/g, minor manual cleanup in some files.
2001-08-04 03:43:19 +08:00
gtk_dialog_set_has_separator (GTK_DIALOG (palette_editor->shell), FALSE);
gtk_widget_hide (GTK_DIALOG (palette_editor->shell)->action_area);
1997-11-25 06:05:25 +08:00
main_vbox = gtk_vbox_new (FALSE, 1);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 4);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (palette_editor->shell)->vbox),
main_vbox);
gtk_widget_show (main_vbox);
/* Palette's name */
palette_editor->name = gtk_entry_new ();
gtk_box_pack_start (GTK_BOX (main_vbox), palette_editor->name,
FALSE, FALSE, 0);
gtk_widget_show (palette_editor->name);
gtk_signal_connect (GTK_OBJECT (palette_editor->name), "activate",
GTK_SIGNAL_FUNC (palette_editor_name_activate),
palette_editor);
gtk_signal_connect (GTK_OBJECT (palette_editor->name), "focus_out_event",
GTK_SIGNAL_FUNC (palette_editor_name_focus_out),
palette_editor);
palette_editor->scrolled_window = scrolledwindow =
gtk_scrolled_window_new (NULL, NULL);
gtk_widget_set_usize (scrolledwindow, -1, PREVIEW_HEIGHT);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_ALWAYS);
gtk_box_pack_start (GTK_BOX (main_vbox), scrolledwindow, TRUE, TRUE, 0);
gtk_widget_show (scrolledwindow);
eventbox = gtk_event_box_new ();
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolledwindow),
eventbox);
set style properties for dockables. 2001-08-03 Michael Natterer <mitch@gimp.org> * gtkrc: set style properties for dockables. * app/main.c: some #if 0'ed code for mem profiling. * app/gui/commands.[ch] * app/gui/menus.c: added a mem profiling menu entry + callback. * app/gui/palette-editor.c: added a #warning as reminder, use gtk_dialog_set_has_separator(). * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpcontainerview.[ch] * app/widgets/gimpdockable.[ch] * app/widgets/gimpdrawablelistview.[ch]: added some style properties to set GimpDockable and friends' borders and spacings. * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch]: GObject stuff, cleanup. * app/docindex.c * app/errorconsole.c * app/gdisplay_color_ui.c * app/gimpprogress.c * app/module_db.c * app/undo_history.c * app/user_install.c * app/gui/channels-commands.c * app/gui/gradient-editor.c * app/gui/info-window.c * app/gui/tips-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpposterizetool.c * app/tools/gimpthresholdtool.c * app/widgets/gimpdatafactoryview.c * libgimp/gimpexport.c * modules/cdisplay_gamma.c * modules/cdisplay_highcontrast.c * plug-ins/[lots of files]: Some perl mass processing applying s/_("Foo")/GTK_STOCK_FOO/g, minor manual cleanup in some files.
2001-08-04 03:43:19 +08:00
gtk_widget_show (eventbox);
gtk_signal_connect (GTK_OBJECT (eventbox), "button_press_event",
GTK_SIGNAL_FUNC (palette_editor_eventbox_button_press),
palette_editor);
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (eventbox), alignment);
gtk_widget_show (alignment);
palette_editor->color_area = palette_region =
gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_preview_set_dither (GTK_PREVIEW (palette_editor->color_area),
GDK_RGB_DITHER_MAX);
gtk_preview_size (GTK_PREVIEW (palette_region), PREVIEW_WIDTH, PREVIEW_HEIGHT);
gtk_widget_set_events (palette_region, PALETTE_EVENT_MASK);
set style properties for dockables. 2001-08-03 Michael Natterer <mitch@gimp.org> * gtkrc: set style properties for dockables. * app/main.c: some #if 0'ed code for mem profiling. * app/gui/commands.[ch] * app/gui/menus.c: added a mem profiling menu entry + callback. * app/gui/palette-editor.c: added a #warning as reminder, use gtk_dialog_set_has_separator(). * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpcontainerview.[ch] * app/widgets/gimpdockable.[ch] * app/widgets/gimpdrawablelistview.[ch]: added some style properties to set GimpDockable and friends' borders and spacings. * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch]: GObject stuff, cleanup. * app/docindex.c * app/errorconsole.c * app/gdisplay_color_ui.c * app/gimpprogress.c * app/module_db.c * app/undo_history.c * app/user_install.c * app/gui/channels-commands.c * app/gui/gradient-editor.c * app/gui/info-window.c * app/gui/tips-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpposterizetool.c * app/tools/gimpthresholdtool.c * app/widgets/gimpdatafactoryview.c * libgimp/gimpexport.c * modules/cdisplay_gamma.c * modules/cdisplay_highcontrast.c * plug-ins/[lots of files]: Some perl mass processing applying s/_("Foo")/GTK_STOCK_FOO/g, minor manual cleanup in some files.
2001-08-04 03:43:19 +08:00
gtk_container_add (GTK_CONTAINER (alignment), palette_region);
gtk_widget_show (palette_region);
gtk_signal_connect (GTK_OBJECT (palette_editor->color_area), "event",
GTK_SIGNAL_FUNC (palette_editor_color_area_events),
palette_editor);
/* dnd stuff */
gtk_drag_source_set (palette_region,
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
color_palette_target_table, n_color_palette_targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gimp_dnd_color_source_set (palette_region, palette_editor_drag_color,
palette_editor);
gtk_drag_dest_set (eventbox,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
color_palette_target_table, n_color_palette_targets,
GDK_ACTION_COPY);
gimp_dnd_color_dest_set (eventbox, palette_editor_drop_color, palette_editor);
gimp_dnd_viewable_dest_set (eventbox, GIMP_TYPE_PALETTE,
palette_editor_drop_palette, palette_editor);
/* The color name entry */
hbox = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
entry = palette_editor->color_name = gtk_entry_new ();
gtk_widget_show (entry);
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
gtk_entry_set_text (GTK_ENTRY (entry), _("Undefined"));
gtk_widget_set_sensitive (entry, FALSE);
set style properties for dockables. 2001-08-03 Michael Natterer <mitch@gimp.org> * gtkrc: set style properties for dockables. * app/main.c: some #if 0'ed code for mem profiling. * app/gui/commands.[ch] * app/gui/menus.c: added a mem profiling menu entry + callback. * app/gui/palette-editor.c: added a #warning as reminder, use gtk_dialog_set_has_separator(). * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpcontainerview.[ch] * app/widgets/gimpdockable.[ch] * app/widgets/gimpdrawablelistview.[ch]: added some style properties to set GimpDockable and friends' borders and spacings. * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch]: GObject stuff, cleanup. * app/docindex.c * app/errorconsole.c * app/gdisplay_color_ui.c * app/gimpprogress.c * app/module_db.c * app/undo_history.c * app/user_install.c * app/gui/channels-commands.c * app/gui/gradient-editor.c * app/gui/info-window.c * app/gui/tips-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpposterizetool.c * app/tools/gimpthresholdtool.c * app/widgets/gimpdatafactoryview.c * libgimp/gimpexport.c * modules/cdisplay_gamma.c * modules/cdisplay_highcontrast.c * plug-ins/[lots of files]: Some perl mass processing applying s/_("Foo")/GTK_STOCK_FOO/g, minor manual cleanup in some files.
2001-08-04 03:43:19 +08:00
palette_editor->entry_sig_id =
gtk_signal_connect (GTK_OBJECT (entry), "changed",
GTK_SIGNAL_FUNC (palette_editor_color_name_changed),
palette_editor);
/* + and - buttons */
button = gimp_pixmap_button_new (zoom_in_xpm, NULL);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
set style properties for dockables. 2001-08-03 Michael Natterer <mitch@gimp.org> * gtkrc: set style properties for dockables. * app/main.c: some #if 0'ed code for mem profiling. * app/gui/commands.[ch] * app/gui/menus.c: added a mem profiling menu entry + callback. * app/gui/palette-editor.c: added a #warning as reminder, use gtk_dialog_set_has_separator(). * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpcontainerview.[ch] * app/widgets/gimpdockable.[ch] * app/widgets/gimpdrawablelistview.[ch]: added some style properties to set GimpDockable and friends' borders and spacings. * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch]: GObject stuff, cleanup. * app/docindex.c * app/errorconsole.c * app/gdisplay_color_ui.c * app/gimpprogress.c * app/module_db.c * app/undo_history.c * app/user_install.c * app/gui/channels-commands.c * app/gui/gradient-editor.c * app/gui/info-window.c * app/gui/tips-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpposterizetool.c * app/tools/gimpthresholdtool.c * app/widgets/gimpdatafactoryview.c * libgimp/gimpexport.c * modules/cdisplay_gamma.c * modules/cdisplay_highcontrast.c * plug-ins/[lots of files]: Some perl mass processing applying s/_("Foo")/GTK_STOCK_FOO/g, minor manual cleanup in some files.
2001-08-04 03:43:19 +08:00
gtk_widget_show (button);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (palette_editor_zoomin_callback),
palette_editor);
button = gimp_pixmap_button_new (zoom_out_xpm, NULL);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
set style properties for dockables. 2001-08-03 Michael Natterer <mitch@gimp.org> * gtkrc: set style properties for dockables. * app/main.c: some #if 0'ed code for mem profiling. * app/gui/commands.[ch] * app/gui/menus.c: added a mem profiling menu entry + callback. * app/gui/palette-editor.c: added a #warning as reminder, use gtk_dialog_set_has_separator(). * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpcontainerview.[ch] * app/widgets/gimpdockable.[ch] * app/widgets/gimpdrawablelistview.[ch]: added some style properties to set GimpDockable and friends' borders and spacings. * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch]: GObject stuff, cleanup. * app/docindex.c * app/errorconsole.c * app/gdisplay_color_ui.c * app/gimpprogress.c * app/module_db.c * app/undo_history.c * app/user_install.c * app/gui/channels-commands.c * app/gui/gradient-editor.c * app/gui/info-window.c * app/gui/tips-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpposterizetool.c * app/tools/gimpthresholdtool.c * app/widgets/gimpdatafactoryview.c * libgimp/gimpexport.c * modules/cdisplay_gamma.c * modules/cdisplay_highcontrast.c * plug-ins/[lots of files]: Some perl mass processing applying s/_("Foo")/GTK_STOCK_FOO/g, minor manual cleanup in some files.
2001-08-04 03:43:19 +08:00
gtk_widget_show (button);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (palette_editor_zoomout_callback),
palette_editor);
gtk_signal_connect (GTK_OBJECT (palette_editor->context), "palette_changed",
GTK_SIGNAL_FUNC (palette_editor_palette_changed),
palette_editor);
palette_editor->invalidate_preview_handler_id =
gimp_container_add_handler (gimp->palette_factory->container,
"invalidate_preview",
GTK_SIGNAL_FUNC (palette_editor_invalidate_preview),
palette_editor);
gtk_widget_realize (palette_editor->shell);
palette_editor_create_popup_menu (palette_editor);
return palette_editor;
}
/* private functions */
static void
palette_editor_name_activate (GtkWidget *widget,
PaletteEditor *palette_editor)
{
GimpPalette *palette;
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning) 2001-07-24 Michael Natterer <mitch@gimp.org> Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning) * configure.in: require glib/gtk+ >= 1.3.7, commented out the gtkxmhtml stuff. From now on, you will need glib, pango, atk and gtk+ HEAD from CVS to hack or use GIMP HEAD. Beware, it crashes randomly :) * app/core/Makefile.am * app/core/gimpmarshal.list: new file plus rules to generate gimpmarshal.[ch] from it. * app/core/* * app/tools/* * app/widgets/* * libgimpwidgets/*: started to use the glib object system. All core/ objects are still gtk objects however. All signals are created using g_signal_new(). There are many gtk+ artefacts left. Finally, we will _not_ use the gtk_signal_foo() wrappers and friends any more. * app/colormaps.c * app/devices.[ch] * app/disp_callbacks.c * app/errorconsole.c * app/file-save.[ch] * app/interface.c * app/module_db.c * app/nav_window.c * app/ops_buttons.c * app/scroll.c * app/user_install.c * app/gui/about-dialog.c * app/gui/brush-editor.c * app/gui/brushes-commands.c * app/gui/color-notebook.c * app/gui/colormap-dialog.c * app/gui/dialogs-commands.c * app/gui/dialogs-constructors.c * app/gui/file-commands.c * app/gui/file-dialog-utils.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/gradients-commands.c * app/gui/image-commands.c * app/gui/info-dialog.[ch] * app/gui/layer-select.c * app/gui/layers-commands.c * app/gui/menus.c * app/gui/offset-dialog.c * app/gui/palette-editor.c * app/gui/palettes-commands.c * app/gui/patterns-commands.c * app/gui/preferences-dialog.c * app/gui/resize-dialog.[ch] * app/gui/splash.c * app/gui/tips-dialog.c * app/gui/tool-options-dialog.c * app/gui/toolbox.c * app/gui/tools-commands.c * libgimp/gimpbrushmenu.c * libgimp/gimpmenu.c * libgimp/gimppatternmenu.c * libgimp/gimpui.c * libgimpbase/gimpenv.c: tons and tons of changes like "const gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete and currently disables), lots of s/gtk_signal/g_signal/, removal/replacement of deprecated stuff, s/GtkSignalFunc/GCallback/ and lots of small changes and fixes while I was on it, zillions of warnings left... * modules/Makefile.am: disabled the water color selector temporarily (XInput issues). * plug-ins/Makefile.am * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl: simply excluded all plug-ins which did not build (including Script-Fu). They are trivial to fix.
2001-07-25 05:27:11 +08:00
const gchar *entry_text;
palette = gimp_context_get_palette (palette_editor->context);
entry_text = gtk_entry_get_text (GTK_ENTRY (widget));
gimp_object_set_name (GIMP_OBJECT (palette), entry_text);
}
static void
palette_editor_name_focus_out (GtkWidget *widget,
GdkEvent *event,
PaletteEditor *palette_editor)
{
palette_editor_name_activate (widget, palette_editor);
}
/* the palette dialog popup menu & callbacks *******************************/
static void
palette_editor_create_popup_menu (PaletteEditor *palette_editor)
{
GtkWidget *menu;
GtkWidget *menu_item;
palette_editor->popup_menu = menu = gtk_menu_new ();
menu_item = gtk_menu_item_new_with_label (_("New"));
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning) 2001-07-24 Michael Natterer <mitch@gimp.org> Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning) * configure.in: require glib/gtk+ >= 1.3.7, commented out the gtkxmhtml stuff. From now on, you will need glib, pango, atk and gtk+ HEAD from CVS to hack or use GIMP HEAD. Beware, it crashes randomly :) * app/core/Makefile.am * app/core/gimpmarshal.list: new file plus rules to generate gimpmarshal.[ch] from it. * app/core/* * app/tools/* * app/widgets/* * libgimpwidgets/*: started to use the glib object system. All core/ objects are still gtk objects however. All signals are created using g_signal_new(). There are many gtk+ artefacts left. Finally, we will _not_ use the gtk_signal_foo() wrappers and friends any more. * app/colormaps.c * app/devices.[ch] * app/disp_callbacks.c * app/errorconsole.c * app/file-save.[ch] * app/interface.c * app/module_db.c * app/nav_window.c * app/ops_buttons.c * app/scroll.c * app/user_install.c * app/gui/about-dialog.c * app/gui/brush-editor.c * app/gui/brushes-commands.c * app/gui/color-notebook.c * app/gui/colormap-dialog.c * app/gui/dialogs-commands.c * app/gui/dialogs-constructors.c * app/gui/file-commands.c * app/gui/file-dialog-utils.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/gradients-commands.c * app/gui/image-commands.c * app/gui/info-dialog.[ch] * app/gui/layer-select.c * app/gui/layers-commands.c * app/gui/menus.c * app/gui/offset-dialog.c * app/gui/palette-editor.c * app/gui/palettes-commands.c * app/gui/patterns-commands.c * app/gui/preferences-dialog.c * app/gui/resize-dialog.[ch] * app/gui/splash.c * app/gui/tips-dialog.c * app/gui/tool-options-dialog.c * app/gui/toolbox.c * app/gui/tools-commands.c * libgimp/gimpbrushmenu.c * libgimp/gimpmenu.c * libgimp/gimppatternmenu.c * libgimp/gimpui.c * libgimpbase/gimpenv.c: tons and tons of changes like "const gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete and currently disables), lots of s/gtk_signal/g_signal/, removal/replacement of deprecated stuff, s/GtkSignalFunc/GCallback/ and lots of small changes and fixes while I was on it, zillions of warnings left... * modules/Makefile.am: disabled the water color selector temporarily (XInput issues). * plug-ins/Makefile.am * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl: simply excluded all plug-ins which did not build (including Script-Fu). They are trivial to fix.
2001-07-25 05:27:11 +08:00
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
set style properties for dockables. 2001-08-03 Michael Natterer <mitch@gimp.org> * gtkrc: set style properties for dockables. * app/main.c: some #if 0'ed code for mem profiling. * app/gui/commands.[ch] * app/gui/menus.c: added a mem profiling menu entry + callback. * app/gui/palette-editor.c: added a #warning as reminder, use gtk_dialog_set_has_separator(). * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpcontainerview.[ch] * app/widgets/gimpdockable.[ch] * app/widgets/gimpdrawablelistview.[ch]: added some style properties to set GimpDockable and friends' borders and spacings. * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch]: GObject stuff, cleanup. * app/docindex.c * app/errorconsole.c * app/gdisplay_color_ui.c * app/gimpprogress.c * app/module_db.c * app/undo_history.c * app/user_install.c * app/gui/channels-commands.c * app/gui/gradient-editor.c * app/gui/info-window.c * app/gui/tips-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpposterizetool.c * app/tools/gimpthresholdtool.c * app/widgets/gimpdatafactoryview.c * libgimp/gimpexport.c * modules/cdisplay_gamma.c * modules/cdisplay_highcontrast.c * plug-ins/[lots of files]: Some perl mass processing applying s/_("Foo")/GTK_STOCK_FOO/g, minor manual cleanup in some files.
2001-08-04 03:43:19 +08:00
gtk_widget_show (menu_item);
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
GTK_SIGNAL_FUNC (palette_editor_new_entry_callback),
palette_editor);
menu_item = gtk_menu_item_new_with_label (_("Edit"));
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning) 2001-07-24 Michael Natterer <mitch@gimp.org> Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning) * configure.in: require glib/gtk+ >= 1.3.7, commented out the gtkxmhtml stuff. From now on, you will need glib, pango, atk and gtk+ HEAD from CVS to hack or use GIMP HEAD. Beware, it crashes randomly :) * app/core/Makefile.am * app/core/gimpmarshal.list: new file plus rules to generate gimpmarshal.[ch] from it. * app/core/* * app/tools/* * app/widgets/* * libgimpwidgets/*: started to use the glib object system. All core/ objects are still gtk objects however. All signals are created using g_signal_new(). There are many gtk+ artefacts left. Finally, we will _not_ use the gtk_signal_foo() wrappers and friends any more. * app/colormaps.c * app/devices.[ch] * app/disp_callbacks.c * app/errorconsole.c * app/file-save.[ch] * app/interface.c * app/module_db.c * app/nav_window.c * app/ops_buttons.c * app/scroll.c * app/user_install.c * app/gui/about-dialog.c * app/gui/brush-editor.c * app/gui/brushes-commands.c * app/gui/color-notebook.c * app/gui/colormap-dialog.c * app/gui/dialogs-commands.c * app/gui/dialogs-constructors.c * app/gui/file-commands.c * app/gui/file-dialog-utils.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/gradients-commands.c * app/gui/image-commands.c * app/gui/info-dialog.[ch] * app/gui/layer-select.c * app/gui/layers-commands.c * app/gui/menus.c * app/gui/offset-dialog.c * app/gui/palette-editor.c * app/gui/palettes-commands.c * app/gui/patterns-commands.c * app/gui/preferences-dialog.c * app/gui/resize-dialog.[ch] * app/gui/splash.c * app/gui/tips-dialog.c * app/gui/tool-options-dialog.c * app/gui/toolbox.c * app/gui/tools-commands.c * libgimp/gimpbrushmenu.c * libgimp/gimpmenu.c * libgimp/gimppatternmenu.c * libgimp/gimpui.c * libgimpbase/gimpenv.c: tons and tons of changes like "const gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete and currently disables), lots of s/gtk_signal/g_signal/, removal/replacement of deprecated stuff, s/GtkSignalFunc/GCallback/ and lots of small changes and fixes while I was on it, zillions of warnings left... * modules/Makefile.am: disabled the water color selector temporarily (XInput issues). * plug-ins/Makefile.am * plug-ins/common/.cvsignore * plug-ins/common/Makefile.am * plug-ins/common/plugin-defs.pl: simply excluded all plug-ins which did not build (including Script-Fu). They are trivial to fix.
2001-07-25 05:27:11 +08:00
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
set style properties for dockables. 2001-08-03 Michael Natterer <mitch@gimp.org> * gtkrc: set style properties for dockables. * app/main.c: some #if 0'ed code for mem profiling. * app/gui/commands.[ch] * app/gui/menus.c: added a mem profiling menu entry + callback. * app/gui/palette-editor.c: added a #warning as reminder, use gtk_dialog_set_has_separator(). * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpcontainerview.[ch] * app/widgets/gimpdockable.[ch] * app/widgets/gimpdrawablelistview.[ch]: added some style properties to set GimpDockable and friends' borders and spacings. * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch]: GObject stuff, cleanup. * app/docindex.c * app/errorconsole.c * app/gdisplay_color_ui.c * app/gimpprogress.c * app/module_db.c * app/undo_history.c * app/user_install.c * app/gui/channels-commands.c * app/gui/gradient-editor.c * app/gui/info-window.c * app/gui/tips-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpposterizetool.c * app/tools/gimpthresholdtool.c * app/widgets/gimpdatafactoryview.c * libgimp/gimpexport.c * modules/cdisplay_gamma.c * modules/cdisplay_highcontrast.c * plug-ins/[lots of files]: Some perl mass processing applying s/_("Foo")/GTK_STOCK_FOO/g, minor manual cleanup in some files.
2001-08-04 03:43:19 +08:00
gtk_widget_show (menu_item);
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
GTK_SIGNAL_FUNC (palette_editor_edit_entry_callback),
palette_editor);
palette_editor->edit_menu_item = menu_item;
menu_item = gtk_menu_item_new_with_label (_("Delete"));
set style properties for dockables. 2001-08-03 Michael Natterer <mitch@gimp.org> * gtkrc: set style properties for dockables. * app/main.c: some #if 0'ed code for mem profiling. * app/gui/commands.[ch] * app/gui/menus.c: added a mem profiling menu entry + callback. * app/gui/palette-editor.c: added a #warning as reminder, use gtk_dialog_set_has_separator(). * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpcontainerview.[ch] * app/widgets/gimpdockable.[ch] * app/widgets/gimpdrawablelistview.[ch]: added some style properties to set GimpDockable and friends' borders and spacings. * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch]: GObject stuff, cleanup. * app/docindex.c * app/errorconsole.c * app/gdisplay_color_ui.c * app/gimpprogress.c * app/module_db.c * app/undo_history.c * app/user_install.c * app/gui/channels-commands.c * app/gui/gradient-editor.c * app/gui/info-window.c * app/gui/tips-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpposterizetool.c * app/tools/gimpthresholdtool.c * app/widgets/gimpdatafactoryview.c * libgimp/gimpexport.c * modules/cdisplay_gamma.c * modules/cdisplay_highcontrast.c * plug-ins/[lots of files]: Some perl mass processing applying s/_("Foo")/GTK_STOCK_FOO/g, minor manual cleanup in some files.
2001-08-04 03:43:19 +08:00
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
gtk_widget_show (menu_item);
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
GTK_SIGNAL_FUNC (palette_editor_delete_entry_callback),
palette_editor);
palette_editor->delete_menu_item = menu_item;
}
static void
palette_editor_new_entry_callback (GtkWidget *widget,
gpointer data)
{
PaletteEditor *palette_editor;
GimpContext *user_context;
GimpRGB color;
palette_editor = (PaletteEditor *) data;
if (! (palette_editor && gimp_context_get_palette (palette_editor->context)))
return;
user_context = gimp_get_user_context (palette_editor->context->gimp);
if (active_color == FOREGROUND)
gimp_context_get_foreground (user_context, &color);
else if (active_color == BACKGROUND)
gimp_context_get_background (user_context, &color);
palette_editor->color =
gimp_palette_add_entry (gimp_context_get_palette (palette_editor->context),
NULL,
&color);
1997-11-25 06:05:25 +08:00
}
static void
palette_editor_edit_entry_callback (GtkWidget *widget,
1999-10-27 02:27:27 +08:00
gpointer data)
1997-11-25 06:05:25 +08:00
{
PaletteEditor *palette_editor;
1997-11-25 06:05:25 +08:00
palette_editor = (PaletteEditor *) data;
if (! (palette_editor && gimp_context_get_palette (palette_editor->context)
&& palette_editor->color))
return;
if (! palette_editor->color_notebook)
{
palette_editor->color_notebook =
color_notebook_new (_("Edit Palette Color"),
(const GimpRGB *) &palette_editor->color->color,
palette_editor_color_notebook_callback,
palette_editor,
FALSE,
FALSE);
palette_editor->color_notebook_active = TRUE;
}
else
1997-11-25 06:05:25 +08:00
{
if (! palette_editor->color_notebook_active)
1997-11-25 06:05:25 +08:00
{
color_notebook_show (palette_editor->color_notebook);
palette_editor->color_notebook_active = TRUE;
1997-11-25 06:05:25 +08:00
}
color_notebook_set_color (palette_editor->color_notebook,
&palette_editor->color->color);
1997-11-25 06:05:25 +08:00
}
}
1999-10-27 02:27:27 +08:00
static void
palette_editor_delete_entry_callback (GtkWidget *widget,
1999-10-27 02:27:27 +08:00
gpointer data)
{
PaletteEditor *palette_editor;
1999-10-27 02:27:27 +08:00
palette_editor = (PaletteEditor *) data;
1999-10-27 02:27:27 +08:00
if (! (palette_editor && gimp_context_get_palette (palette_editor->context) &&
palette_editor->color))
return;
gimp_palette_delete_entry (gimp_context_get_palette (palette_editor->context),
palette_editor->color);
1999-10-27 02:27:27 +08:00
}
1997-11-25 06:05:25 +08:00
static void
palette_editor_color_notebook_callback (ColorNotebook *color_notebook,
const GimpRGB *color,
ColorNotebookState state,
gpointer data)
1997-11-25 06:05:25 +08:00
{
PaletteEditor *palette_editor;
GimpContext *user_context;
GimpPalette *palette;
set style properties for dockables. 2001-08-03 Michael Natterer <mitch@gimp.org> * gtkrc: set style properties for dockables. * app/main.c: some #if 0'ed code for mem profiling. * app/gui/commands.[ch] * app/gui/menus.c: added a mem profiling menu entry + callback. * app/gui/palette-editor.c: added a #warning as reminder, use gtk_dialog_set_has_separator(). * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpcontainerview.[ch] * app/widgets/gimpdockable.[ch] * app/widgets/gimpdrawablelistview.[ch]: added some style properties to set GimpDockable and friends' borders and spacings. * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch]: GObject stuff, cleanup. * app/docindex.c * app/errorconsole.c * app/gdisplay_color_ui.c * app/gimpprogress.c * app/module_db.c * app/undo_history.c * app/user_install.c * app/gui/channels-commands.c * app/gui/gradient-editor.c * app/gui/info-window.c * app/gui/tips-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimplevelstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpposterizetool.c * app/tools/gimpthresholdtool.c * app/widgets/gimpdatafactoryview.c * libgimp/gimpexport.c * modules/cdisplay_gamma.c * modules/cdisplay_highcontrast.c * plug-ins/[lots of files]: Some perl mass processing applying s/_("Foo")/GTK_STOCK_FOO/g, minor manual cleanup in some files.
2001-08-04 03:43:19 +08:00
palette_editor = (PaletteEditor *) data;
palette = gimp_context_get_palette (palette_editor->context);
user_context = gimp_get_user_context (palette_editor->context->gimp);
switch (state)
{
case COLOR_NOTEBOOK_UPDATE:
break;
case COLOR_NOTEBOOK_OK:
if (palette_editor->color)
{
palette_editor->color->color = *color;
/* Update either foreground or background colors */
if (active_color == FOREGROUND)
gimp_context_set_foreground (user_context, color);
else if (active_color == BACKGROUND)
gimp_context_set_background (user_context, color);
gimp_data_dirty (GIMP_DATA (palette));
}
/* Fallthrough */
case COLOR_NOTEBOOK_CANCEL:
if (palette_editor->color_notebook_active)
{
color_notebook_hide (palette_editor->color_notebook);
palette_editor->color_notebook_active = FALSE;
}
}
1997-11-25 06:05:25 +08:00
}
/* the color area event callbacks ******************************************/
static gint
palette_editor_eventbox_button_press (GtkWidget *widget,
GdkEventButton *bevent,
PaletteEditor *palette_editor)
{
if (gtk_get_event_widget ((GdkEvent *) bevent) == palette_editor->color_area)
return FALSE;
if (bevent->button == 3)
{
if (GTK_WIDGET_SENSITIVE (palette_editor->edit_menu_item))
{
gtk_widget_set_sensitive (palette_editor->edit_menu_item, FALSE);
gtk_widget_set_sensitive (palette_editor->delete_menu_item, FALSE);
}
gtk_menu_popup (GTK_MENU (palette_editor->popup_menu), NULL, NULL,
NULL, NULL, 3,
bevent->time);
}
return TRUE;
}
1999-10-27 02:27:27 +08:00
static gint
palette_editor_color_area_events (GtkWidget *widget,
1999-10-27 02:27:27 +08:00
GdkEvent *event,
PaletteEditor *palette_editor)
1997-11-25 06:05:25 +08:00
{
GimpContext *user_context;
GdkEventButton *bevent;
GList *list;
gint entry_width;
gint entry_height;
gint row, col;
gint pos;
1997-11-25 06:05:25 +08:00
user_context = gimp_get_user_context (palette_editor->context->gimp);
switch (event->type)
1997-11-25 06:05:25 +08:00
{
case GDK_EXPOSE:
palette_editor_redraw (palette_editor);
break;
case GDK_BUTTON_PRESS:
bevent = (GdkEventButton *) event;
entry_width = palette_editor->col_width + SPACING;
entry_height = (ENTRY_HEIGHT * palette_editor->zoom_factor) + SPACING;
col = (bevent->x - 1) / entry_width;
row = (bevent->y - 1) / entry_height;
pos = row * palette_editor->columns + col;
if (gimp_context_get_palette (palette_editor->context))
list = g_list_nth (gimp_context_get_palette (palette_editor->context)->colors, pos);
else
list = NULL;
if (list)
palette_editor->dnd_color = list->data;
else
palette_editor->dnd_color = NULL;
if ((bevent->button == 1 || bevent->button == 3) &&
gimp_context_get_palette (palette_editor->context))
1997-11-25 06:05:25 +08:00
{
if (list)
1997-11-25 06:05:25 +08:00
{
if (palette_editor->color)
1997-11-25 06:05:25 +08:00
{
palette_editor->freeze_update = TRUE;
palette_editor_draw_entries (palette_editor, -1, -1);
palette_editor->freeze_update = FALSE;
1997-11-25 06:05:25 +08:00
}
palette_editor->color = (GimpPaletteEntry *) list->data;
1997-11-25 06:05:25 +08:00
if (active_color == FOREGROUND)
{
if (bevent->state & GDK_CONTROL_MASK)
gimp_context_set_background (user_context,
&palette_editor->color->color);
else
gimp_context_set_foreground (user_context,
&palette_editor->color->color);
}
else if (active_color == BACKGROUND)
{
if (bevent->state & GDK_CONTROL_MASK)
gimp_context_set_foreground (user_context,
&palette_editor->color->color);
else
gimp_context_set_background (user_context,
&palette_editor->color->color);
}
1997-11-25 06:05:25 +08:00
palette_editor_draw_entries (palette_editor, row, col);
/* Update the active color name */
g_print ("color name before: >>%s<<\n",
palette_editor->color->name);
gtk_entry_set_text (GTK_ENTRY (palette_editor->color_name),
palette_editor->color->name);
g_print ("color name after: >>%s<<\n",
palette_editor->color->name);
gtk_widget_set_sensitive (palette_editor->color_name, TRUE);
/* palette_update_current_entry (palette_editor); */
if (bevent->button == 3)
{
if (! GTK_WIDGET_SENSITIVE (palette_editor->edit_menu_item))
{
gtk_widget_set_sensitive (palette_editor->edit_menu_item, TRUE);
gtk_widget_set_sensitive (palette_editor->delete_menu_item, TRUE);
}
gtk_menu_popup (GTK_MENU (palette_editor->popup_menu),
NULL, NULL,
NULL, NULL, 3,
bevent->time);
}
}
else
{
1999-10-27 02:27:27 +08:00
if (bevent->button == 3)
{
if (GTK_WIDGET_SENSITIVE (palette_editor->edit_menu_item))
{
gtk_widget_set_sensitive (palette_editor->edit_menu_item, FALSE);
gtk_widget_set_sensitive (palette_editor->delete_menu_item, FALSE);
}
gtk_menu_popup (GTK_MENU (palette_editor->popup_menu),
NULL, NULL,
NULL, NULL, 3,
bevent->time);
}
1997-11-25 06:05:25 +08:00
}
}
break;
default:
break;
1997-11-25 06:05:25 +08:00
}
return FALSE;
1997-11-25 06:05:25 +08:00
}
1999-10-27 02:27:27 +08:00
/* functions for drawing & updating the palette dialog color area **********/
1997-11-25 06:05:25 +08:00
static gint
palette_editor_draw_color_row (guchar *colors,
gint n_colors,
1999-10-27 02:27:27 +08:00
gint y,
gint column_highlight,
guchar *buffer,
PaletteEditor *palette_editor)
{
guchar *p;
guchar bcolor;
gint width, height;
gint entry_width;
gint entry_height;
gint vsize;
gint vspacing;
gint i, j;
GtkWidget *preview;
if (! palette_editor)
return -1;
preview = palette_editor->color_area;
1997-11-25 06:05:25 +08:00
bcolor = 0;
width = preview->requisition.width;
height = preview->requisition.height;
entry_width = palette_editor->col_width;
entry_height = (ENTRY_HEIGHT * palette_editor->zoom_factor);
1997-11-25 06:05:25 +08:00
if ((y >= 0) && ((y + SPACING) < height))
vspacing = SPACING;
else if (y < 0)
vspacing = SPACING + y;
else
vspacing = height - y;
if (vspacing > 0)
{
if (y < 0)
y += SPACING - vspacing;
for (i = SPACING - vspacing; i < SPACING; i++, y++)
{
p = buffer;
for (j = 0; j < width; j++)
{
*p++ = bcolor;
*p++ = bcolor;
*p++ = bcolor;
}
if (column_highlight >= 0)
{
guchar *ph;
ph = &buffer[3 * column_highlight * (entry_width + SPACING)];
for (j = 0 ; j <= entry_width + SPACING; j++)
{
*ph++ = ~bcolor;
*ph++ = ~bcolor;
*ph++ = ~bcolor;
}
gtk_preview_draw_row (GTK_PREVIEW (preview), buffer, 0,
y + entry_height + 1, width);
}
1997-11-25 06:05:25 +08:00
gtk_preview_draw_row (GTK_PREVIEW (preview), buffer, 0, y, width);
}
if (y > SPACING)
y += SPACING - vspacing;
}
else
y += SPACING;
vsize = (y >= 0) ? (entry_height) : (entry_height + y);
if ((y >= 0) && ((y + entry_height) < height))
vsize = entry_height;
else if (y < 0)
vsize = entry_height + y;
else
vsize = height - y;
if (vsize > 0)
{
p = buffer;
for (i = 0; i < n_colors; i++)
1997-11-25 06:05:25 +08:00
{
for (j = 0; j < SPACING; j++)
{
*p++ = bcolor;
*p++ = bcolor;
*p++ = bcolor;
}
for (j = 0; j < entry_width; j++)
{
*p++ = colors[i * 3];
*p++ = colors[i * 3 + 1];
*p++ = colors[i * 3 + 2];
1997-11-25 06:05:25 +08:00
}
}
for (i = 0; i < (palette_editor->columns - n_colors); i++)
1997-11-25 06:05:25 +08:00
{
for (j = 0; j < (SPACING + entry_width); j++)
{
*p++ = 0;
*p++ = 0;
*p++ = 0;
}
}
for (j = 0; j < SPACING; j++)
{
if (n_colors == column_highlight)
{
*p++ = ~bcolor;
*p++ = ~bcolor;
*p++ = ~bcolor;
}
else
{
*p++ = bcolor;
*p++ = bcolor;
*p++ = bcolor;
}
1997-11-25 06:05:25 +08:00
}
if (y < 0)
y += entry_height - vsize;
for (i = 0; i < vsize; i++, y++)
{
if (column_highlight >= 0)
{
guchar *ph;
ph = &buffer[3 * column_highlight * (entry_width + SPACING)];
*ph++ = ~bcolor;
*ph++ = ~bcolor;
*ph++ = ~bcolor;
ph += 3 * (entry_width);
*ph++ = ~bcolor;
*ph++ = ~bcolor;
*ph++ = ~bcolor;
}
gtk_preview_draw_row (GTK_PREVIEW (preview), buffer, 0, y, width);
}
1997-11-25 06:05:25 +08:00
if (y > entry_height)
y += entry_height - vsize;
}
else
y += entry_height;
return y;
}
static void
palette_editor_draw_entries (PaletteEditor *palette_editor,
1999-10-27 02:27:27 +08:00
gint row_start,
gint column_highlight)
1997-11-25 06:05:25 +08:00
{
GimpPaletteEntry *entry;
guchar *buffer;
guchar *colors;
GList *list;
gint width, height;
gint entry_width;
gint entry_height;
gint index, y;
1997-11-25 06:05:25 +08:00
if (! (palette_editor && gimp_context_get_palette (palette_editor->context)))
return;
1997-11-25 06:05:25 +08:00
width = palette_editor->color_area->requisition.width;
height = palette_editor->color_area->requisition.height;
1997-11-25 06:05:25 +08:00
entry_width = palette_editor->col_width;
entry_height = (ENTRY_HEIGHT * palette_editor->zoom_factor);
if (entry_width <= 0)
return;
1997-11-25 06:05:25 +08:00
colors = g_new (guchar, palette_editor->columns * 3);
buffer = g_new (guchar, width * 3);
if (row_start < 0)
{
y = 0;
list = gimp_context_get_palette (palette_editor->context)->colors;
column_highlight = -1;
}
else
{
y = (entry_height + SPACING) * row_start;
list = g_list_nth (gimp_context_get_palette (palette_editor->context)->colors,
row_start * palette_editor->columns);
}
1997-11-25 06:05:25 +08:00
index = 0;
1997-11-25 06:05:25 +08:00
for (; list; list = g_list_next (list))
{
entry = (GimpPaletteEntry *) list->data;
1997-11-25 06:05:25 +08:00
gimp_rgb_get_uchar (&entry->color,
&colors[index * 3],
&colors[index * 3 + 1],
&colors[index * 3 + 2]);
index++;
if (index == palette_editor->columns)
1997-11-25 06:05:25 +08:00
{
index = 0;
y = palette_editor_draw_color_row (colors, palette_editor->columns, y,
column_highlight, buffer,
palette_editor);
1997-11-25 06:05:25 +08:00
if (y >= height || row_start >= 0)
{
/* This row only */
gtk_widget_draw (palette_editor->color_area, NULL);
g_free (buffer);
g_free (colors);
return;
}
}
}
while (y < height)
{
y = palette_editor_draw_color_row (colors, index, y, column_highlight,
buffer, palette_editor);
index = 0;
if (row_start >= 0)
break;
1997-11-25 06:05:25 +08:00
}
g_free (buffer);
g_free (colors);
if (! palette_editor->freeze_update)
gtk_widget_draw (palette_editor->color_area, NULL);
1997-11-25 06:05:25 +08:00
}
static void
palette_editor_scroll_top_left (PaletteEditor *palette_editor)
1997-11-25 06:05:25 +08:00
{
GtkAdjustment *hadj;
GtkAdjustment *vadj;
1997-11-25 06:05:25 +08:00
if (! (palette_editor && palette_editor->scrolled_window))
return;
1999-10-27 02:27:27 +08:00
hadj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (palette_editor->scrolled_window));
vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (palette_editor->scrolled_window));
if (hadj)
gtk_adjustment_set_value (hadj, 0.0);
if (vadj)
gtk_adjustment_set_value (vadj, 0.0);
}
1997-11-25 06:05:25 +08:00
static void
palette_editor_redraw (PaletteEditor *palette_editor)
{
gint vsize;
gint nrows;
gint n_entries;
gint preview_width;
guint width;
if (! gimp_context_get_palette (palette_editor->context))
return;
width = palette_editor->color_area->parent->parent->parent->allocation.width;
if ((palette_editor->columns_valid) && palette_editor->last_width == width)
return;
palette_editor->last_width = width;
palette_editor->col_width = width / (palette_editor->columns + 1) - SPACING;
if (palette_editor->col_width < 0) palette_editor->col_width = 0;
palette_editor->columns_valid = TRUE;
n_entries = gimp_context_get_palette (palette_editor->context)->n_colors;
nrows = n_entries / palette_editor->columns;
if (n_entries % palette_editor->columns)
nrows += 1;
1997-11-25 06:05:25 +08:00
vsize = nrows * (SPACING + (gint) (ENTRY_HEIGHT * palette_editor->zoom_factor)) + SPACING;
Add default to Cancel button, remove unset GTK_RECEIVES_DEFAULT from Sat Feb 20 16:12:33 CST 1999 Shawn T. Amundson <amundson@gimp.org> * app/tips_dialog.c: Add default to Cancel button, remove unset GTK_RECEIVES_DEFAULT from prev/next buttons (they are like toolbar buttons), changed abreviated prev to previous, prev/next button are now same size, cancel button is in a button box. Added vboxes where necessary to prevent prev/next and check button from filling vertically. * app/app_procs.c: when splashscreen dialog is larger than the logo, (due to huge font), center logo. * app/file_new_dialog.c: patch from Marco Lamb <lm@geocities.com> disallows resizing, changes vertical expanding of widgets to not occur * app/palette.c: patch from Marco Lamb <lm@geocities.com>. Makes +/- buttons for zoom pixmaps (eventually, these can be replaced with a magnifying glass with a little +/- I think), so that they no longer expand as they did before. I modified his patch so it did not create a misused toolbar. I did some other stuff here too, moved Close button to the left, made it the window's default, and unset GTK_RECEIVES_DEFAULT off of the non-bottom buttons. * app/actionarea.c: another patch from Marco Lamb <lm@geocities.com>. This one changes buttons to be put in a button box which is right justified. If we decide later that spread is better, we can change this easy enough. * app/tools/zoom_in.xpm, app/tools/zoom_out.xpm: + and - graphics. * libgimp/gimpunit.h libgimp/gimpunit.c: New files from Michael Natterer <mitschel@cs.tu-berlin.de>, gimp_unit_* routines. * app/gimage.h app/gimpimage.h app/gimpimage.c app/gimpimageP.h app/xcf.c: Patches from Michael Natterer <mitschel@cs.tu-berlin.de>, which keep a unit assocated with an image.
1999-02-21 10:08:15 +08:00
preview_width =
(palette_editor->col_width + SPACING) * palette_editor->columns + SPACING;
1997-11-25 06:05:25 +08:00
gtk_preview_size (GTK_PREVIEW (palette_editor->color_area),
preview_width, vsize);
gtk_widget_queue_resize (palette_editor->color_area);
1997-11-25 06:05:25 +08:00
palette_editor_draw_entries (palette_editor, -1, -1);
if (palette_editor->color)
{
palette_editor_draw_entries (palette_editor,
palette_editor->color->position / palette_editor->columns,
palette_editor->color->position % palette_editor->columns);
}
1997-11-25 06:05:25 +08:00
}
static void
palette_editor_palette_changed (GimpContext *context,
GimpPalette *palette,
gpointer data)
1997-11-25 06:05:25 +08:00
{
PaletteEditor *palette_editor;
1997-11-25 06:05:25 +08:00
palette_editor = (PaletteEditor *) data;
/* FIXME */
if (! palette)
return;
gtk_entry_set_text (GTK_ENTRY (palette_editor->name),
gimp_object_get_name (GIMP_OBJECT (palette)));
if (palette_editor->color_notebook_active)
{
color_notebook_hide (palette_editor->color_notebook);
palette_editor->color_notebook_active = FALSE;
1997-11-25 06:05:25 +08:00
}
if (palette_editor->color_notebook)
color_notebook_free (palette_editor->color_notebook);
palette_editor->color_notebook = NULL;
palette_editor->columns_valid = FALSE;
palette_editor_redraw (palette_editor);
1997-11-25 06:05:25 +08:00
palette_editor_scroll_top_left (palette_editor);
palette_editor->color = NULL;
1997-11-25 06:05:25 +08:00
/* Stop errors in case no colors are selected */
gtk_signal_handler_block (GTK_OBJECT (palette_editor->color_name),
palette_editor->entry_sig_id);
gtk_entry_set_text (GTK_ENTRY (palette_editor->color_name), _("Undefined"));
gtk_widget_set_sensitive (palette_editor->color_name, FALSE);
gtk_signal_handler_unblock (GTK_OBJECT (palette_editor->color_name),
palette_editor->entry_sig_id);
}
1997-11-25 06:05:25 +08:00
1999-10-27 02:27:27 +08:00
/* the color name entry callback *******************************************/
static void
palette_editor_color_name_changed (GtkWidget *widget,
gpointer data)
{
PaletteEditor *palette_editor;
palette_editor = (PaletteEditor *) data;
g_return_if_fail (gimp_context_get_palette (palette_editor->context) != NULL);
if (palette_editor->color->name)
g_free (palette_editor->color->name);
palette_editor->color->name =
g_strdup (gtk_entry_get_text (GTK_ENTRY (palette_editor->color_name)));
gimp_data_dirty (GIMP_DATA (gimp_context_get_palette (palette_editor->context)));
1999-10-27 02:27:27 +08:00
}
1999-10-27 02:27:27 +08:00
/* palette zoom functions & callbacks **************************************/
1999-10-27 02:27:27 +08:00
static void
palette_editor_zoomin_callback (GtkWidget *widget,
gpointer data)
{
PaletteEditor *palette_editor;
palette_editor = (PaletteEditor *) data;
palette_editor->zoom_factor += 0.1;
palette_editor_redraw_zoom (palette_editor);
1999-10-27 02:27:27 +08:00
}
1999-10-27 02:27:27 +08:00
static void
palette_editor_zoomout_callback (GtkWidget *widget,
1999-10-27 02:27:27 +08:00
gpointer data)
{
PaletteEditor *palette_editor;
palette_editor = (PaletteEditor *) data;
palette_editor->zoom_factor -= 0.1;
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
palette_editor_redraw_zoom (palette_editor);
1999-10-27 02:27:27 +08:00
}
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
1999-10-27 02:27:27 +08:00
static void
palette_editor_redraw_zoom (PaletteEditor *palette_editor)
1999-10-27 02:27:27 +08:00
{
if (palette_editor->zoom_factor > 4.0)
{
palette_editor->zoom_factor = 4.0;
}
else if (palette_editor->zoom_factor < 0.1)
{
palette_editor->zoom_factor = 0.1;
}
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
palette_editor->columns = COLUMNS;
palette_editor->columns_valid = FALSE;
palette_editor_redraw (palette_editor);
Made a GimpContainer out of the palette list: 2001-02-11 Michael Natterer <mitch@gimp.org> Made a GimpContainer out of the palette list: * app/Makefile.am * app/palettes.[ch]: new files for the global palette list. * app/gimpgradientpreview.[ch] * app/gimppalettepreview.[ch]: new widgets. * app/gimppalette.[ch]: derive it from GimpData to get all the preview etc. stuff. * app/datafiles.[ch]: new function datafiles_check_extension(), added a "loader_data" parameter to datafiles_read_directories() and pass it to the loader function. * app/gimpcontext.[ch]: added the palette (not really used yet except by the test dialogs). * app/gimpdatalist.[ch]: new function gimp_data_list_save_and_clear() which does everything needed for patterns_free(), brushes_free() ... * app/gimpdnd.c: added palette DND. * app/app_procs.c * app/brushes.c * app/color_notebook.h * app/commands.c * app/convert.c * app/gimpbrush.h * app/gimpbrushpipe.h * app/gimpgradient.c * app/gimppattern.h * app/gimppreview.c * app/gradients.c * app/module_db.c * app/palette.[ch] * app/paletteP.h * app/palette_import.c * app/palette_select.[ch] * app/patterns.c * app/plug_in.c * app/pdb/convert_cmds.c * app/pdb/palette_cmds.c * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/palette.pdb: lotsa stuff: changed due to the above API changes, #define the file extensions in the GimpData subclasses' header files instead of hardcoding them in several places, ... * data/palettes/*: The same file format change as for the gradient files: - Save the palette name in a parsable form (as part of the file format, not in a comment. - Removed unserscores from the palette names. - Added an extension (Gimp PaLettes are ".gpl" files now ;-)
2001-02-12 00:14:25 +08:00
palette_editor_scroll_top_left (palette_editor);
1999-10-27 02:27:27 +08:00
}
/* the palette dialog action callbacks **************************************/
1999-10-27 02:27:27 +08:00
static void
palette_editor_close_callback (GtkWidget *widget,
1999-10-27 02:27:27 +08:00
gpointer data)
{
PaletteEditor *palette_editor;
1999-10-27 02:27:27 +08:00
palette_editor = (PaletteEditor *) data;
1999-10-27 02:27:27 +08:00
if (palette_editor)
1999-10-27 02:27:27 +08:00
{
if (palette_editor->color_notebook_active)
1999-10-27 02:27:27 +08:00
{
color_notebook_hide (palette_editor->color_notebook);
palette_editor->color_notebook_active = FALSE;
1999-10-27 02:27:27 +08:00
}
if (GTK_WIDGET_VISIBLE (palette_editor->shell))
gtk_widget_hide (palette_editor->shell);
1999-10-27 02:27:27 +08:00
}
}
/* the palette dialog color dnd callbacks **********************************/
static void
palette_editor_drag_color (GtkWidget *widget,
GimpRGB *color,
1999-10-27 02:27:27 +08:00
gpointer data)
{
PaletteEditor *palette_editor;
1999-10-27 02:27:27 +08:00
palette_editor = (PaletteEditor *) data;
1999-10-27 02:27:27 +08:00
if (palette_editor &&
gimp_context_get_palette (palette_editor->context) &&
palette_editor->dnd_color)
1999-10-27 02:27:27 +08:00
{
*color = palette_editor->dnd_color->color;
}
else
{
gimp_rgba_set (color, 0.0, 0.0, 0.0, 1.0);
1999-10-27 02:27:27 +08:00
}
}
static void
palette_editor_drop_color (GtkWidget *widget,
const GimpRGB *color,
gpointer data)
1999-10-27 02:27:27 +08:00
{
PaletteEditor *palette_editor;
1999-10-27 02:27:27 +08:00
palette_editor = (PaletteEditor *) data;
1999-10-27 02:27:27 +08:00
if (palette_editor && gimp_context_get_palette (palette_editor->context))
1999-10-27 02:27:27 +08:00
{
palette_editor->color =
gimp_palette_add_entry (gimp_context_get_palette (palette_editor->context),
NULL,
(GimpRGB *) color);
1999-10-27 02:27:27 +08:00
}
}
static void
palette_editor_drop_palette (GtkWidget *widget,
GimpViewable *viewable,
gpointer data)
{
PaletteEditor *palette_editor;
GimpPalette *palette;
palette_editor = (PaletteEditor *) data;
palette = GIMP_PALETTE (viewable);
if (palette_editor)
{
gimp_context_set_palette (palette_editor->context, palette);
}
}
static void
palette_editor_invalidate_preview (GimpPalette *palette,
PaletteEditor *palette_editor)
1999-10-27 02:27:27 +08:00
{
if (palette == gimp_context_get_palette (palette_editor->context))
1999-10-27 02:27:27 +08:00
{
palette_editor->columns_valid = FALSE;
palette_editor_redraw (palette_editor);
}
}