2000-02-26 11:41:06 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-1999 Peter Mattis and Spencer Kimball
|
1999-02-22 03:50:37 +08:00
|
|
|
*
|
|
|
|
* gimpunitmenu.c
|
2000-02-12 21:07:59 +08:00
|
|
|
* Copyright (C) 1999 Michael Natterer <mitch@gimp.org>
|
1999-02-22 03:50:37 +08:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
1999-11-18 05:13:50 +08:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1999-02-22 03:50:37 +08:00
|
|
|
* License as published by the Free Software Foundation; either
|
2000-02-26 11:41:06 +08:00
|
|
|
* version 2 of the License, or (at your option) any later version.
|
2003-10-01 07:19:48 +08:00
|
|
|
*
|
2000-02-26 11:41:06 +08:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2003-10-01 07:19:48 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
1999-02-22 03:50:37 +08:00
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
1999-11-18 05:13:50 +08:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1999-02-22 03:50:37 +08:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2000-05-31 07:38:46 +08:00
|
|
|
|
1999-05-30 00:35:47 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-05-31 07:38:46 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-05-21 21:58:46 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
|
|
|
|
#include "gimpwidgetstypes.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2000-01-11 23:48:00 +08:00
|
|
|
#include "gimpdialog.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "gimphelpui.h"
|
1999-02-22 03:50:37 +08:00
|
|
|
#include "gimpunitmenu.h"
|
2003-10-01 07:19:48 +08:00
|
|
|
#include "gimpwidgets.h"
|
1999-02-22 03:50:37 +08:00
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimp/libgimp-intl.h"
|
1999-02-22 03:50:37 +08:00
|
|
|
|
2000-05-31 07:38:46 +08:00
|
|
|
|
1999-12-02 21:00:18 +08:00
|
|
|
enum
|
|
|
|
{
|
1999-06-18 03:13:08 +08:00
|
|
|
UNIT_CHANGED,
|
1999-02-22 03:50:37 +08:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2001-11-12 02:35:25 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
UNIT_COLUMN,
|
|
|
|
FACTOR_COLUMN,
|
|
|
|
DATA_COLUMN,
|
|
|
|
NUM_COLUMNS
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
2005-12-21 04:35:23 +08:00
|
|
|
static void gimp_unit_menu_finalize (GObject *object);
|
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
|
|
|
|
2005-12-21 04:35:23 +08:00
|
|
|
static const gchar * gimp_unit_menu_build_string (const gchar *format,
|
2006-04-12 18:53:28 +08:00
|
|
|
GimpUnit unit);
|
2005-12-21 04:35:23 +08:00
|
|
|
static void gimp_unit_menu_callback (GtkWidget *widget,
|
2006-04-12 18:53:28 +08:00
|
|
|
gpointer data);
|
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
|
|
|
|
|
|
|
|
2006-05-15 17:46:31 +08:00
|
|
|
G_DEFINE_TYPE (GimpUnitMenu, gimp_unit_menu, GTK_TYPE_OPTION_MENU)
|
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
|
|
|
|
2005-12-21 04:35:23 +08:00
|
|
|
#define parent_class gimp_unit_menu_parent_class
|
1999-03-26 07:14:36 +08:00
|
|
|
|
2005-12-21 04:35:23 +08:00
|
|
|
static guint gimp_unit_menu_signals[LAST_SIGNAL] = { 0 };
|
2003-10-01 07:19:48 +08:00
|
|
|
|
1999-02-22 03:50:37 +08:00
|
|
|
|
|
|
|
static void
|
2001-01-08 07:59:46 +08:00
|
|
|
gimp_unit_menu_class_init (GimpUnitMenuClass *klass)
|
1999-02-22 03:50:37 +08:00
|
|
|
{
|
2004-07-13 22:55:16 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
1999-02-22 03:50:37 +08:00
|
|
|
|
2003-12-18 21:29:16 +08:00
|
|
|
/**
|
|
|
|
* GimpUnitMenu::unit-changed:
|
|
|
|
*
|
|
|
|
* This signal is emitted whenever the user selects a #GimpUnit from
|
|
|
|
* the #GimpUnitMenu.
|
|
|
|
**/
|
2003-10-01 07:19:48 +08:00
|
|
|
gimp_unit_menu_signals[UNIT_CHANGED] =
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_new ("unit-changed",
|
2006-04-12 18:53:28 +08:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpUnitMenuClass, unit_changed),
|
|
|
|
NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
1999-02-22 03:50:37 +08:00
|
|
|
|
2001-09-21 18:47:19 +08:00
|
|
|
object_class->finalize = gimp_unit_menu_finalize;
|
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
|
|
|
|
2001-09-21 18:47:19 +08:00
|
|
|
klass->unit_changed = NULL;
|
1999-06-18 03:13:08 +08:00
|
|
|
}
|
1999-02-22 03:50:37 +08:00
|
|
|
|
|
|
|
static void
|
2003-02-10 21:16:35 +08:00
|
|
|
gimp_unit_menu_init (GimpUnitMenu *menu)
|
1999-02-22 03:50:37 +08:00
|
|
|
{
|
2003-02-10 21:16:35 +08:00
|
|
|
menu->format = NULL;
|
|
|
|
menu->unit = GIMP_UNIT_PIXEL;
|
|
|
|
menu->show_pixels = FALSE;
|
|
|
|
menu->show_percent = FALSE;
|
|
|
|
menu->selection = NULL;
|
|
|
|
menu->tv = NULL;
|
1999-02-22 03:50:37 +08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
static void
|
2001-09-21 18:47:19 +08:00
|
|
|
gimp_unit_menu_finalize (GObject *object)
|
1999-02-22 03:50:37 +08:00
|
|
|
{
|
2005-12-21 04:35:23 +08:00
|
|
|
GimpUnitMenu *menu = GIMP_UNIT_MENU (object);
|
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
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
if (menu->format)
|
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
|
|
|
{
|
2003-02-10 21:16:35 +08:00
|
|
|
g_free (menu->format);
|
|
|
|
menu->format = NULL;
|
1999-02-22 03:50:37 +08:00
|
|
|
}
|
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
|
|
|
|
2001-09-21 18:47:19 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
1999-02-22 03:50:37 +08:00
|
|
|
}
|
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
/**
|
|
|
|
* gimp_unit_menu_new:
|
2001-08-04 03:52:08 +08:00
|
|
|
* @format: A printf-like format string which is used to create the unit
|
|
|
|
* strings.
|
|
|
|
* @unit: The initially selected unit.
|
2003-02-07 05:17:12 +08:00
|
|
|
* @show_pixels: %TRUE if the unit menu should contain an item for
|
2001-08-04 03:52:08 +08:00
|
|
|
* GIMP_UNIT_PIXEL.
|
2003-02-07 05:17:12 +08:00
|
|
|
* @show_percent: %TRUE in the unit menu should contain an item for
|
2000-02-08 04:35:13 +08:00
|
|
|
* GIMP_UNIT_PERCENT.
|
2003-02-07 05:17:12 +08:00
|
|
|
* @show_custom: %TRUE if the unit menu should contain a "More..." item for
|
2001-08-04 03:52:08 +08:00
|
|
|
* opening the user-defined-unit selection dialog.
|
2000-02-08 04:35:13 +08:00
|
|
|
*
|
|
|
|
* Creates a new #GimpUnitMenu widget.
|
|
|
|
*
|
|
|
|
* The @format string supports the following percent expansions:
|
|
|
|
*
|
2003-11-15 22:02:24 +08:00
|
|
|
* <informaltable pgwide="1" frame="none" role="enum">
|
|
|
|
* <tgroup cols="2"><colspec colwidth="1*"/><colspec colwidth="8*"/>
|
|
|
|
* <tbody>
|
|
|
|
* <row>
|
|
|
|
* <entry>% f</entry>
|
|
|
|
* <entry>Factor (how many units make up an inch)</entry>
|
|
|
|
* </row>
|
|
|
|
* <row>
|
|
|
|
* <entry>% y</entry>
|
|
|
|
* <entry>Symbol (e.g. "''" for GIMP_UNIT_INCH)</entry>
|
|
|
|
* </row>
|
|
|
|
* <row>
|
|
|
|
* <entry>% a</entry>
|
|
|
|
* <entry>Abbreviation</entry>
|
|
|
|
* </row>
|
|
|
|
* <row>
|
|
|
|
* <entry>% s</entry>
|
|
|
|
* <entry>Singular</entry>
|
|
|
|
* </row>
|
|
|
|
* <row>
|
|
|
|
* <entry>% p</entry>
|
|
|
|
* <entry>Plural</entry>
|
|
|
|
* </row>
|
|
|
|
* <row>
|
|
|
|
* <entry>%%</entry>
|
|
|
|
* <entry>Literal percent</entry>
|
|
|
|
* </row>
|
|
|
|
* </tbody>
|
|
|
|
* </tgroup>
|
|
|
|
* </informaltable>
|
|
|
|
*
|
2000-02-08 04:35:13 +08:00
|
|
|
* Returns: A pointer to the new #GimpUnitMenu widget.
|
2001-08-04 03:52:08 +08:00
|
|
|
**/
|
1999-12-02 21:00:18 +08:00
|
|
|
GtkWidget *
|
2000-11-18 08:25:42 +08:00
|
|
|
gimp_unit_menu_new (const gchar *format,
|
2006-04-12 18:53:28 +08:00
|
|
|
GimpUnit unit,
|
|
|
|
gboolean show_pixels,
|
|
|
|
gboolean show_percent,
|
|
|
|
gboolean show_custom)
|
1999-02-22 03:50:37 +08:00
|
|
|
{
|
2003-02-10 21:16:35 +08:00
|
|
|
GimpUnitMenu *unit_menu;
|
1999-03-17 04:14:07 +08:00
|
|
|
GtkWidget *menu;
|
|
|
|
GtkWidget *menuitem;
|
2000-02-08 04:35:13 +08:00
|
|
|
GimpUnit u;
|
1999-03-17 04:14:07 +08:00
|
|
|
|
2001-12-02 22:59:30 +08:00
|
|
|
g_return_val_if_fail (((unit >= GIMP_UNIT_PIXEL) &&
|
2006-04-12 18:53:28 +08:00
|
|
|
(unit < gimp_unit_get_number_of_units ())) ||
|
|
|
|
(unit == GIMP_UNIT_PERCENT), NULL);
|
1999-02-22 03:50:37 +08:00
|
|
|
|
2003-11-16 06:53:28 +08:00
|
|
|
if ((unit >= gimp_unit_get_number_of_built_in_units ()) &&
|
2000-02-08 04:35:13 +08:00
|
|
|
(unit != GIMP_UNIT_PERCENT))
|
1999-04-05 20:48:48 +08:00
|
|
|
show_custom = TRUE;
|
1999-02-22 03:50:37 +08:00
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
unit_menu = g_object_new (GIMP_TYPE_UNIT_MENU, NULL);
|
1999-02-22 03:50:37 +08:00
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
unit_menu->format = g_strdup (format);
|
|
|
|
unit_menu->show_pixels = show_pixels;
|
|
|
|
unit_menu->show_percent = show_percent;
|
1999-02-22 03:50:37 +08:00
|
|
|
|
1999-12-02 21:00:18 +08:00
|
|
|
menu = gtk_menu_new ();
|
2000-02-08 04:35:13 +08:00
|
|
|
for (u = show_pixels ? GIMP_UNIT_PIXEL : GIMP_UNIT_INCH;
|
2003-11-16 06:53:28 +08:00
|
|
|
u < gimp_unit_get_number_of_built_in_units ();
|
1999-04-05 20:48:48 +08:00
|
|
|
u++)
|
1999-02-22 03:50:37 +08:00
|
|
|
{
|
1999-04-06 20:13:54 +08:00
|
|
|
/* special cases "pixels" and "percent" */
|
2000-02-08 04:35:13 +08:00
|
|
|
if (u == GIMP_UNIT_INCH)
|
2006-04-12 18:53:28 +08:00
|
|
|
{
|
|
|
|
if (show_percent)
|
|
|
|
{
|
|
|
|
menuitem =
|
|
|
|
gtk_menu_item_new_with_label
|
|
|
|
(gimp_unit_menu_build_string (format, GIMP_UNIT_PERCENT));
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
g_object_set_data (G_OBJECT (menuitem), "gimp_unit_menu",
|
2001-11-12 02:35:25 +08:00
|
|
|
GINT_TO_POINTER (GIMP_UNIT_PERCENT));
|
2006-04-12 18:53:28 +08:00
|
|
|
gtk_widget_show (menuitem);
|
2001-08-04 03:52:08 +08:00
|
|
|
|
2006-04-12 18:53:28 +08:00
|
|
|
g_signal_connect (menuitem, "activate",
|
2001-08-04 03:52:08 +08:00
|
|
|
G_CALLBACK (gimp_unit_menu_callback),
|
2003-02-10 21:16:35 +08:00
|
|
|
unit_menu);
|
2006-04-12 18:53:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (show_pixels || show_percent)
|
|
|
|
{
|
|
|
|
menuitem = gtk_menu_item_new ();
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
|
|
|
gtk_widget_set_sensitive (menuitem, FALSE);
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
}
|
|
|
|
}
|
1999-04-06 20:13:54 +08:00
|
|
|
|
1999-02-22 03:50:37 +08:00
|
|
|
menuitem =
|
2006-04-12 18:53:28 +08:00
|
|
|
gtk_menu_item_new_with_label (gimp_unit_menu_build_string (format, u));
|
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), menuitem);
|
2001-07-31 19:33:13 +08:00
|
|
|
g_object_set_data (G_OBJECT (menuitem), "gimp_unit_menu",
|
2001-11-12 02:35:25 +08:00
|
|
|
GINT_TO_POINTER (u));
|
1999-03-26 07:14:36 +08:00
|
|
|
gtk_widget_show (menuitem);
|
2001-08-04 03:52:08 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (menuitem, "activate",
|
2001-08-04 03:52:08 +08:00
|
|
|
G_CALLBACK (gimp_unit_menu_callback),
|
2003-02-10 21:16:35 +08:00
|
|
|
unit_menu);
|
1999-03-17 04:14:07 +08:00
|
|
|
}
|
1999-03-26 07:14:36 +08:00
|
|
|
|
2003-11-16 06:53:28 +08:00
|
|
|
if ((unit >= gimp_unit_get_number_of_built_in_units ()) &&
|
2000-02-08 04:35:13 +08:00
|
|
|
(unit != GIMP_UNIT_PERCENT))
|
1999-03-17 04:14:07 +08:00
|
|
|
{
|
|
|
|
menuitem = gtk_menu_item_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), menuitem);
|
2000-12-03 22:41:20 +08:00
|
|
|
gtk_widget_set_sensitive (menuitem, FALSE);
|
1999-03-17 04:14:07 +08:00
|
|
|
gtk_widget_show (menuitem);
|
2003-10-01 07:19:48 +08:00
|
|
|
|
1999-03-17 04:14:07 +08:00
|
|
|
menuitem =
|
2006-04-12 18:53:28 +08:00
|
|
|
gtk_menu_item_new_with_label (gimp_unit_menu_build_string (format,
|
2003-02-07 05:17:12 +08:00
|
|
|
unit));
|
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), menuitem);
|
2003-10-01 07:19:48 +08:00
|
|
|
g_object_set_data (G_OBJECT (menuitem), "gimp_unit_menu",
|
2001-11-12 02:35:25 +08:00
|
|
|
GINT_TO_POINTER (unit));
|
1999-12-04 02:30:35 +08:00
|
|
|
gtk_widget_show (menuitem);
|
2001-08-04 03:52:08 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (menuitem, "activate",
|
2001-08-04 03:52:08 +08:00
|
|
|
G_CALLBACK (gimp_unit_menu_callback),
|
2003-02-10 21:16:35 +08:00
|
|
|
unit_menu);
|
1999-03-17 04:14:07 +08:00
|
|
|
}
|
1999-02-22 03:50:37 +08:00
|
|
|
|
1999-04-05 20:48:48 +08:00
|
|
|
if (show_custom)
|
1999-03-26 07:14:36 +08:00
|
|
|
{
|
|
|
|
menuitem = gtk_menu_item_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), menuitem);
|
2000-12-03 22:41:20 +08:00
|
|
|
gtk_widget_set_sensitive (menuitem, FALSE);
|
1999-03-26 07:14:36 +08:00
|
|
|
gtk_widget_show (menuitem);
|
1999-04-06 20:13:54 +08:00
|
|
|
|
1999-03-26 07:14:36 +08:00
|
|
|
menuitem =
|
2006-04-12 18:53:28 +08:00
|
|
|
gtk_menu_item_new_with_label (_("More..."));
|
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), menuitem);
|
2001-07-31 19:33:13 +08:00
|
|
|
g_object_set_data (G_OBJECT (menuitem), "gimp_unit_menu",
|
2001-11-12 02:35:25 +08:00
|
|
|
GINT_TO_POINTER (GIMP_UNIT_PERCENT + 1));
|
1999-12-04 02:30:35 +08:00
|
|
|
gtk_widget_show (menuitem);
|
2001-08-04 03:52:08 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (menuitem, "activate",
|
2001-08-04 03:52:08 +08:00
|
|
|
G_CALLBACK (gimp_unit_menu_callback),
|
2003-02-10 21:16:35 +08:00
|
|
|
unit_menu);
|
1999-03-26 07:14:36 +08:00
|
|
|
}
|
1999-04-06 20:13:54 +08:00
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
gtk_option_menu_set_menu (GTK_OPTION_MENU (unit_menu), menu);
|
1999-02-22 03:50:37 +08:00
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
unit_menu->unit = unit;
|
|
|
|
gtk_option_menu_set_history (GTK_OPTION_MENU (unit_menu),
|
2006-04-12 18:53:28 +08:00
|
|
|
(unit == GIMP_UNIT_PIXEL) ? 0 :
|
|
|
|
((unit == GIMP_UNIT_PERCENT) ?
|
|
|
|
(show_pixels ? 1 : 0) :
|
|
|
|
(((show_pixels || show_percent) ? 2 : 0) +
|
|
|
|
((show_pixels && show_percent) ? 1 : 0) +
|
|
|
|
((unit < GIMP_UNIT_END) ?
|
|
|
|
(unit - 1) : GIMP_UNIT_END))));
|
2000-02-08 04:35:13 +08:00
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
return GTK_WIDGET (unit_menu);
|
1999-02-22 03:50:37 +08:00
|
|
|
}
|
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
/**
|
|
|
|
* gimp_unit_menu_set_unit:
|
2003-02-10 21:16:35 +08:00
|
|
|
* @menu: The unit menu you want to set the unit for.
|
2000-02-08 04:35:13 +08:00
|
|
|
* @unit: The new unit.
|
|
|
|
*
|
|
|
|
* Sets a new #GimpUnit for the specified #GimpUnitMenu.
|
2001-08-04 03:52:08 +08:00
|
|
|
**/
|
1999-02-22 03:50:37 +08:00
|
|
|
void
|
2003-02-10 21:16:35 +08:00
|
|
|
gimp_unit_menu_set_unit (GimpUnitMenu *menu,
|
2006-04-12 18:53:28 +08:00
|
|
|
GimpUnit unit)
|
1999-02-22 03:50:37 +08:00
|
|
|
{
|
1999-03-17 04:14:07 +08:00
|
|
|
GtkWidget *menuitem = NULL;
|
|
|
|
GList *items;
|
|
|
|
gint user_unit;
|
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
g_return_if_fail (GIMP_IS_UNIT_MENU (menu));
|
2000-02-08 04:35:13 +08:00
|
|
|
g_return_if_fail (((unit >= GIMP_UNIT_PIXEL) &&
|
2006-04-12 18:53:28 +08:00
|
|
|
((unit > GIMP_UNIT_PIXEL) || menu->show_pixels) &&
|
|
|
|
(unit < gimp_unit_get_number_of_units ())) ||
|
|
|
|
((unit == GIMP_UNIT_PERCENT) && menu->show_percent));
|
1999-03-12 11:44:59 +08:00
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
if (unit == menu->unit)
|
1999-03-17 04:14:07 +08:00
|
|
|
return;
|
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
items = GTK_MENU_SHELL (GTK_OPTION_MENU (menu)->menu)->children;
|
2000-02-08 04:35:13 +08:00
|
|
|
user_unit = (GIMP_UNIT_END +
|
2006-04-12 18:53:28 +08:00
|
|
|
(((menu->show_pixels || menu->show_percent) ? 2 : 0) +
|
|
|
|
((menu->show_pixels && menu->show_percent) ? 1 : 0)));
|
1999-03-12 11:44:59 +08:00
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
if ((unit >= GIMP_UNIT_END) && (unit != GIMP_UNIT_PERCENT))
|
1999-03-17 04:14:07 +08:00
|
|
|
{
|
|
|
|
if ((g_list_length (items) - 3) >= user_unit)
|
2006-04-12 18:53:28 +08:00
|
|
|
{
|
|
|
|
gtk_widget_destroy (GTK_WIDGET (g_list_nth_data (items,
|
|
|
|
user_unit - 1)));
|
|
|
|
gtk_widget_destroy (GTK_WIDGET (g_list_nth_data (items,
|
|
|
|
user_unit - 1)));
|
|
|
|
}
|
1999-03-17 04:14:07 +08:00
|
|
|
|
|
|
|
menuitem = gtk_menu_item_new ();
|
2003-02-10 21:16:35 +08:00
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (GTK_OPTION_MENU (menu)->menu),
|
2006-04-12 18:53:28 +08:00
|
|
|
menuitem);
|
2000-12-04 02:35:58 +08:00
|
|
|
gtk_widget_set_sensitive (menuitem, FALSE);
|
2003-02-10 21:16:35 +08:00
|
|
|
gtk_menu_reorder_child (GTK_MENU (GTK_OPTION_MENU (menu)->menu),
|
2006-04-12 18:53:28 +08:00
|
|
|
menuitem, user_unit - 1);
|
1999-12-04 02:30:35 +08:00
|
|
|
gtk_widget_show (menuitem);
|
2003-10-01 07:19:48 +08:00
|
|
|
|
1999-03-17 04:14:07 +08:00
|
|
|
menuitem =
|
2006-04-12 18:53:28 +08:00
|
|
|
gtk_menu_item_new_with_label (gimp_unit_menu_build_string (menu->format,
|
|
|
|
unit));
|
2003-02-10 21:16:35 +08:00
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (GTK_OPTION_MENU (menu)->menu),
|
2006-04-12 18:53:28 +08:00
|
|
|
menuitem);
|
2001-07-31 19:33:13 +08:00
|
|
|
g_object_set_data (G_OBJECT (menuitem), "gimp_unit_menu",
|
2001-11-12 02:35:25 +08:00
|
|
|
GINT_TO_POINTER (unit));
|
2003-02-10 21:16:35 +08:00
|
|
|
gtk_menu_reorder_child (GTK_MENU (GTK_OPTION_MENU (menu)->menu),
|
2006-04-12 18:53:28 +08:00
|
|
|
menuitem, user_unit);
|
1999-12-04 02:30:35 +08:00
|
|
|
gtk_widget_show (menuitem);
|
2001-08-04 03:52:08 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (menuitem, "activate",
|
2001-08-04 03:52:08 +08:00
|
|
|
G_CALLBACK (gimp_unit_menu_callback),
|
2003-02-10 21:16:35 +08:00
|
|
|
menu);
|
1999-03-17 04:14:07 +08:00
|
|
|
}
|
1999-02-22 03:50:37 +08:00
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
menu->unit = unit;
|
|
|
|
gtk_option_menu_set_history (GTK_OPTION_MENU (menu),
|
2006-04-12 18:53:28 +08:00
|
|
|
(unit == GIMP_UNIT_PIXEL) ? 0 :
|
|
|
|
((unit == GIMP_UNIT_PERCENT) ?
|
|
|
|
(menu->show_pixels ? 1 : 0) :
|
|
|
|
(((menu->show_pixels ||
|
|
|
|
menu->show_percent) ? 2 : 0) +
|
|
|
|
((menu->show_pixels &&
|
|
|
|
menu->show_percent) ? 1 : 0) +
|
|
|
|
((unit < GIMP_UNIT_END) ?
|
|
|
|
(unit - 1) : GIMP_UNIT_END))));
|
2003-10-01 07:19:48 +08:00
|
|
|
|
|
|
|
g_signal_emit (menu, gimp_unit_menu_signals[UNIT_CHANGED], 0);
|
1999-02-22 03:50:37 +08:00
|
|
|
}
|
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
/**
|
|
|
|
* gimp_unit_menu_get_unit:
|
2003-02-10 21:16:35 +08:00
|
|
|
* @menu: The unit menu you want to know the unit of.
|
2000-02-08 04:35:13 +08:00
|
|
|
*
|
|
|
|
* Returns the #GimpUnit the user has selected from the #GimpUnitMenu.
|
|
|
|
*
|
|
|
|
* Returns: The unit the user has selected.
|
2001-08-04 03:52:08 +08:00
|
|
|
**/
|
2000-02-08 04:35:13 +08:00
|
|
|
GimpUnit
|
2003-02-10 21:16:35 +08:00
|
|
|
gimp_unit_menu_get_unit (GimpUnitMenu *menu)
|
1999-02-22 03:50:37 +08:00
|
|
|
{
|
2003-02-10 21:16:35 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_UNIT_MENU (menu), GIMP_UNIT_INCH);
|
1999-03-12 11:44:59 +08:00
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
return menu->unit;
|
1999-02-22 03:50:37 +08:00
|
|
|
}
|
|
|
|
|
2003-10-01 07:19:48 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_unit_menu_set_pixel_digits:
|
|
|
|
* @menu: a #GimpUnitMenu
|
|
|
|
* @digits: the number of digits to display for a pixel size
|
|
|
|
*
|
|
|
|
* A GimpUnitMenu can be setup to control the number of digits shown
|
|
|
|
* by attached spinbuttons. Please refer to the documentation of
|
|
|
|
* gimp_unit_menu_update() to see how this is done.
|
|
|
|
*
|
|
|
|
* This function allows to specify the number of digits shown for a
|
|
|
|
* size in pixels. Usually this is 0 (only full pixels). If you want
|
|
|
|
* to allow the user to specify sub-pixel sizes using the attached
|
|
|
|
* spinbuttons, specify the number of digits after the decimal point
|
|
|
|
* here. You should do this after attaching your spinbuttons.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_unit_menu_set_pixel_digits (GimpUnitMenu *menu,
|
|
|
|
gint digits)
|
|
|
|
{
|
|
|
|
GimpUnit unit;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_UNIT_MENU (menu));
|
|
|
|
|
|
|
|
menu->pixel_digits = digits;
|
|
|
|
|
|
|
|
gimp_unit_menu_update (GTK_WIDGET (menu), &unit);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_unit_menu_get_pixel_digits:
|
|
|
|
* @menu: a #GimpUnitMenu
|
|
|
|
*
|
|
|
|
* Retrieve the number of digits for a pixel size as set by
|
|
|
|
* gimp_unit_set_pixel_digits().
|
|
|
|
*
|
|
|
|
* Return value: the configured number of digits for a pixel size
|
|
|
|
**/
|
|
|
|
gint
|
|
|
|
gimp_unit_menu_get_pixel_digits (GimpUnitMenu *menu)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_UNIT_MENU (menu), 0);
|
|
|
|
|
|
|
|
return menu->pixel_digits;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-04-05 20:48:48 +08:00
|
|
|
/* most of the next two functions is stolen from app/gdisplay.c */
|
1999-12-02 21:00:18 +08:00
|
|
|
static gint
|
|
|
|
print (gchar *buf,
|
|
|
|
gint len,
|
|
|
|
gint start,
|
|
|
|
const gchar *fmt,
|
|
|
|
...)
|
1999-02-22 03:50:37 +08:00
|
|
|
{
|
|
|
|
va_list args;
|
1999-12-02 21:00:18 +08:00
|
|
|
gint printed;
|
1999-02-22 03:50:37 +08:00
|
|
|
|
|
|
|
va_start (args, fmt);
|
|
|
|
|
|
|
|
printed = g_vsnprintf (buf + start, len - start, fmt, args);
|
|
|
|
if (printed < 0)
|
|
|
|
printed = len - start;
|
|
|
|
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
return printed;
|
|
|
|
}
|
|
|
|
|
1999-12-02 21:00:18 +08:00
|
|
|
static const gchar *
|
2000-11-18 08:25:42 +08:00
|
|
|
gimp_unit_menu_build_string (const gchar *format,
|
2006-04-12 18:53:28 +08:00
|
|
|
GimpUnit unit)
|
1999-02-22 03:50:37 +08:00
|
|
|
{
|
1999-12-04 02:30:35 +08:00
|
|
|
static gchar buffer[64];
|
1999-12-02 21:00:18 +08:00
|
|
|
gint i = 0;
|
1999-02-22 03:50:37 +08:00
|
|
|
|
1999-12-04 02:30:35 +08:00
|
|
|
while (i < (sizeof (buffer) - 1) && *format)
|
1999-02-22 03:50:37 +08:00
|
|
|
{
|
|
|
|
switch (*format)
|
2006-04-12 18:53:28 +08:00
|
|
|
{
|
|
|
|
case '%':
|
|
|
|
format++;
|
|
|
|
switch (*format)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
g_warning ("%s: unit-menu-format string ended within %%-sequence",
|
2004-05-12 16:13:33 +08:00
|
|
|
G_STRFUNC);
|
2006-04-12 18:53:28 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case '%':
|
|
|
|
buffer[i++] = '%';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'f': /* factor (how many units make up an inch) */
|
|
|
|
i += print (buffer, sizeof (buffer), i, "%f",
|
|
|
|
gimp_unit_get_factor (unit));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'y': /* symbol ("''" for inch) */
|
|
|
|
i += print (buffer, sizeof (buffer), i, "%s",
|
|
|
|
gimp_unit_get_symbol (unit));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'a': /* abbreviation */
|
|
|
|
i += print (buffer, sizeof (buffer), i, "%s",
|
|
|
|
gimp_unit_get_abbreviation (unit));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 's': /* singular */
|
|
|
|
i += print (buffer, sizeof (buffer), i, "%s",
|
|
|
|
gimp_unit_get_singular (unit));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'p': /* plural */
|
|
|
|
i += print (buffer, sizeof (buffer), i, "%s",
|
|
|
|
gimp_unit_get_plural (unit));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_warning ("%s: unit-menu-format contains unknown format "
|
2004-05-12 16:13:33 +08:00
|
|
|
"sequence '%%%c'", G_STRFUNC, *format);
|
2006-04-12 18:53:28 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
1999-03-26 07:14:36 +08:00
|
|
|
|
2006-04-12 18:53:28 +08:00
|
|
|
default:
|
|
|
|
buffer[i++] = *format;
|
|
|
|
break;
|
|
|
|
}
|
2003-10-01 07:19:48 +08:00
|
|
|
|
1999-02-22 03:50:37 +08:00
|
|
|
format++;
|
|
|
|
}
|
1999-12-02 21:00:18 +08:00
|
|
|
|
1999-12-04 02:30:35 +08:00
|
|
|
buffer[MIN (i, sizeof (buffer) - 1)] = 0;
|
1999-12-02 21:00:18 +08:00
|
|
|
|
1999-02-22 03:50:37 +08:00
|
|
|
return buffer;
|
1999-06-18 03:13:08 +08:00
|
|
|
}
|
1999-03-17 04:14:07 +08:00
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
/* private callback of gimp_unit_menu_create_selection () */
|
1999-03-17 04:14:07 +08:00
|
|
|
static void
|
2003-11-06 23:27:05 +08:00
|
|
|
gimp_unit_menu_selection_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
GimpUnitMenu *menu)
|
1999-03-17 04:14:07 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
1999-03-17 04:14:07 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
GtkTreeSelection *sel;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (menu->tv));
|
|
|
|
if (menu->selection && gtk_tree_selection_get_selected (sel, &model,
|
|
|
|
&iter))
|
|
|
|
{
|
|
|
|
GValue val = { 0, };
|
|
|
|
GimpUnit unit;
|
|
|
|
|
|
|
|
gtk_tree_model_get_value (model, &iter, 2, &val);
|
|
|
|
unit = (GimpUnit) g_value_get_int (&val);
|
|
|
|
g_value_unset (&val);
|
|
|
|
|
|
|
|
gimp_unit_menu_set_unit (menu, unit);
|
|
|
|
}
|
1999-03-17 04:14:07 +08:00
|
|
|
}
|
2003-11-06 23:27:05 +08:00
|
|
|
|
|
|
|
gtk_widget_destroy (menu->selection);
|
1999-03-17 04:14:07 +08:00
|
|
|
}
|
|
|
|
|
2000-02-28 08:45:58 +08:00
|
|
|
static void
|
2001-11-12 02:35:25 +08:00
|
|
|
gimp_unit_menu_selection_row_activated_callback (GtkTreeView *tv,
|
2006-04-12 18:53:28 +08:00
|
|
|
GtkTreePath *path,
|
|
|
|
GtkTreeViewColumn *column,
|
|
|
|
GimpUnitMenu *menu)
|
2000-02-28 08:45:58 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
gtk_dialog_response (GTK_DIALOG (menu->selection), GTK_RESPONSE_OK);
|
2000-02-28 08:45:58 +08:00
|
|
|
}
|
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
/* private function of gimp_unit_menu_callback () */
|
1999-03-17 04:14:07 +08:00
|
|
|
static void
|
2003-02-10 21:16:35 +08:00
|
|
|
gimp_unit_menu_create_selection (GimpUnitMenu *menu)
|
1999-03-17 04:14:07 +08:00
|
|
|
{
|
2001-11-12 02:35:25 +08:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *scrolled_win;
|
|
|
|
GtkListStore *list;
|
|
|
|
GtkTreeSelection *sel;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path;
|
|
|
|
GimpUnit unit;
|
|
|
|
gint num_units;
|
2000-01-11 23:48:00 +08:00
|
|
|
|
2003-11-08 01:29:02 +08:00
|
|
|
menu->selection = gimp_dialog_new (_("Unit Selection"), "gimp-unit-selection",
|
2003-11-06 23:27:05 +08:00
|
|
|
GTK_WIDGET (menu),
|
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
2004-01-21 01:10:16 +08:00
|
|
|
gimp_standard_help_func, "gimp-unit-dialog",
|
2000-01-11 23:48:00 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
2000-01-11 23:48:00 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
NULL);
|
1999-03-17 04:14:07 +08:00
|
|
|
|
2005-02-10 19:00:46 +08:00
|
|
|
gtk_dialog_set_alternative_button_order (GTK_DIALOG (menu->selection),
|
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
g_object_add_weak_pointer (G_OBJECT (menu->selection),
|
|
|
|
(gpointer) &menu->selection);
|
2000-02-08 04:35:13 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
g_signal_connect (menu->selection, "response",
|
|
|
|
G_CALLBACK (gimp_unit_menu_selection_response),
|
|
|
|
menu);
|
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
g_signal_connect_object (menu, "unmap",
|
2001-07-31 19:33:13 +08:00
|
|
|
G_CALLBACK (gtk_widget_destroy),
|
2003-02-10 21:16:35 +08:00
|
|
|
menu->selection, G_CONNECT_SWAPPED);
|
1999-03-17 04:14:07 +08:00
|
|
|
|
1999-12-04 02:30:35 +08:00
|
|
|
/* the main vbox */
|
|
|
|
vbox = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
2003-02-10 21:16:35 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (menu->selection)->vbox), vbox);
|
1999-12-04 02:30:35 +08:00
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
|
|
|
/* the selection list */
|
1999-03-17 04:14:07 +08:00
|
|
|
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
|
2001-11-12 02:35:25 +08:00
|
|
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
|
2006-04-12 18:53:28 +08:00
|
|
|
GTK_SHADOW_ETCHED_IN);
|
1999-12-02 21:00:18 +08:00
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
|
2006-04-12 18:53:28 +08:00
|
|
|
GTK_POLICY_NEVER,
|
|
|
|
GTK_POLICY_ALWAYS);
|
1999-12-04 02:30:35 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (vbox), scrolled_win);
|
|
|
|
gtk_widget_show (scrolled_win);
|
1999-12-02 21:00:18 +08:00
|
|
|
|
2001-11-12 02:35:25 +08:00
|
|
|
list = gtk_list_store_new (NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING,
|
2006-04-12 18:53:28 +08:00
|
|
|
G_TYPE_INT);
|
2003-02-10 21:16:35 +08:00
|
|
|
menu->tv = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list));
|
2001-11-12 02:35:25 +08:00
|
|
|
g_object_unref (list);
|
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (menu->tv),
|
2006-04-12 18:53:28 +08:00
|
|
|
-1, _("Unit"),
|
|
|
|
gtk_cell_renderer_text_new (),
|
|
|
|
"text", UNIT_COLUMN, NULL);
|
2003-02-10 21:16:35 +08:00
|
|
|
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (menu->tv),
|
2006-04-12 18:53:28 +08:00
|
|
|
-1, _("Factor"),
|
|
|
|
gtk_cell_renderer_text_new (),
|
|
|
|
"text", FACTOR_COLUMN, NULL);
|
2001-11-12 02:35:25 +08:00
|
|
|
|
1999-12-04 13:33:07 +08:00
|
|
|
/* the unit lines */
|
2003-11-16 06:53:28 +08:00
|
|
|
num_units = gimp_unit_get_number_of_units ();
|
2000-02-08 04:35:13 +08:00
|
|
|
for (unit = GIMP_UNIT_END; unit < num_units; unit++)
|
1999-12-04 13:33:07 +08:00
|
|
|
{
|
2001-11-12 02:35:25 +08:00
|
|
|
gtk_list_store_append (list, &iter);
|
|
|
|
gtk_list_store_set (list, &iter,
|
2006-04-12 18:53:28 +08:00
|
|
|
UNIT_COLUMN,
|
|
|
|
gimp_unit_menu_build_string (menu->format, unit),
|
|
|
|
-1);
|
2001-11-12 02:35:25 +08:00
|
|
|
gtk_list_store_set (list, &iter,
|
2006-04-12 18:53:28 +08:00
|
|
|
FACTOR_COLUMN,
|
|
|
|
gimp_unit_menu_build_string ("(%f)", unit),
|
|
|
|
-1);
|
2001-11-12 02:35:25 +08:00
|
|
|
gtk_list_store_set (list, &iter, DATA_COLUMN, unit, -1);
|
1999-12-04 13:33:07 +08:00
|
|
|
}
|
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
gtk_widget_set_size_request (menu->tv, -1, 150);
|
1999-12-04 13:33:07 +08:00
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled_win), menu->tv);
|
1999-12-04 13:33:07 +08:00
|
|
|
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_connect (menu->tv, "row-activated",
|
2001-11-12 02:35:25 +08:00
|
|
|
G_CALLBACK (gimp_unit_menu_selection_row_activated_callback),
|
2003-02-10 21:16:35 +08:00
|
|
|
menu);
|
1999-03-17 04:14:07 +08:00
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
gtk_widget_show (menu->tv);
|
2001-11-12 02:35:25 +08:00
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
g_signal_connect (menu->tv, "destroy",
|
2001-07-31 19:33:13 +08:00
|
|
|
G_CALLBACK (gtk_widget_destroyed),
|
2003-02-10 21:16:35 +08:00
|
|
|
&menu->tv);
|
1999-03-17 04:14:07 +08:00
|
|
|
|
1999-12-04 02:30:35 +08:00
|
|
|
gtk_widget_show (vbox);
|
2003-02-10 21:16:35 +08:00
|
|
|
gtk_widget_show (menu->selection);
|
1999-03-17 04:14:07 +08:00
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
if (menu->unit >= GIMP_UNIT_END)
|
1999-03-17 04:14:07 +08:00
|
|
|
{
|
2001-11-12 02:35:25 +08:00
|
|
|
path = gtk_tree_path_new ();
|
2003-02-10 21:16:35 +08:00
|
|
|
gtk_tree_path_append_index (path, menu->unit - GIMP_UNIT_END);
|
2001-11-12 02:35:25 +08:00
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (menu->tv));
|
2001-11-12 02:35:25 +08:00
|
|
|
gtk_tree_selection_select_path (sel, path);
|
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (menu->tv), path, NULL,
|
2006-04-12 18:53:28 +08:00
|
|
|
FALSE, 0.0, 0.0);
|
1999-03-17 04:14:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-02-22 03:50:37 +08:00
|
|
|
static void
|
|
|
|
gimp_unit_menu_callback (GtkWidget *widget,
|
2006-04-12 18:53:28 +08:00
|
|
|
gpointer data)
|
1999-02-22 03:50:37 +08:00
|
|
|
{
|
2004-07-13 22:55:16 +08:00
|
|
|
GimpUnitMenu *menu = data;
|
2000-02-08 04:35:13 +08:00
|
|
|
GimpUnit new_unit;
|
1999-02-22 03:50:37 +08:00
|
|
|
|
2003-01-06 04:38:21 +08:00
|
|
|
new_unit = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget),
|
|
|
|
"gimp_unit_menu"));
|
2003-10-01 07:19:48 +08:00
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
if (menu->unit == new_unit)
|
1999-02-22 03:50:37 +08:00
|
|
|
return;
|
|
|
|
|
1999-04-05 20:48:48 +08:00
|
|
|
/* was "More..." selected? */
|
2000-02-08 04:35:13 +08:00
|
|
|
if (new_unit == (GIMP_UNIT_PERCENT + 1))
|
1999-03-17 04:14:07 +08:00
|
|
|
{
|
2003-02-10 21:16:35 +08:00
|
|
|
gtk_option_menu_set_history (GTK_OPTION_MENU (menu),
|
2006-04-12 18:53:28 +08:00
|
|
|
(menu->unit == GIMP_UNIT_PIXEL) ? 0 :
|
|
|
|
((menu->unit == GIMP_UNIT_PERCENT) ?
|
|
|
|
(menu->show_pixels ? 1 : 0) :
|
|
|
|
((menu->show_pixels ||
|
|
|
|
menu->show_percent ? 2 : 0) +
|
|
|
|
(menu->show_pixels &&
|
|
|
|
menu->show_percent ? 1 : 0) +
|
|
|
|
((menu->unit < GIMP_UNIT_END) ?
|
|
|
|
menu->unit - 1 : GIMP_UNIT_END))));
|
2003-02-10 21:16:35 +08:00
|
|
|
if (! menu->selection)
|
2006-04-12 18:53:28 +08:00
|
|
|
gimp_unit_menu_create_selection (menu);
|
1999-03-17 04:14:07 +08:00
|
|
|
return;
|
|
|
|
}
|
2003-02-10 21:16:35 +08:00
|
|
|
else if (menu->selection)
|
1999-03-17 04:14:07 +08:00
|
|
|
{
|
2003-02-10 21:16:35 +08:00
|
|
|
gtk_widget_destroy (menu->selection);
|
1999-03-17 04:14:07 +08:00
|
|
|
}
|
|
|
|
|
2003-02-10 21:16:35 +08:00
|
|
|
gimp_unit_menu_set_unit (menu, new_unit);
|
1999-02-22 03:50:37 +08:00
|
|
|
}
|