2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2000-03-01 02:25:05 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2007-06-06 16:44:52 +08:00
|
|
|
* This is a plug-in for GIMP.
|
2000-03-01 02:25:05 +08:00
|
|
|
*
|
|
|
|
* Copyright (C) 2000 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2000-03-01 02:25:05 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2000-03-01 02:25:05 +08:00
|
|
|
* (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
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2000-03-01 02:25:05 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2004-11-04 18:06:22 +08:00
|
|
|
|
2000-10-01 04:13:06 +08:00
|
|
|
#include <string.h>
|
2000-03-01 02:25:05 +08:00
|
|
|
|
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
|
|
|
|
|
|
|
#include "libgimp/stdplugins-intl.h"
|
|
|
|
|
2002-11-29 21:57:30 +08:00
|
|
|
|
2005-08-16 06:42:34 +08:00
|
|
|
#define PLUG_IN_PROC "plug-in-unit-editor"
|
2008-03-24 23:29:55 +08:00
|
|
|
#define PLUG_IN_BINARY "unit-editor"
|
2011-04-09 02:31:34 +08:00
|
|
|
#define PLUG_IN_ROLE "gimp-unit-editor"
|
2003-11-06 23:27:05 +08:00
|
|
|
#define RESPONSE_REFRESH 1
|
|
|
|
|
2002-11-29 21:57:30 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
SAVE,
|
|
|
|
IDENTIFIER,
|
|
|
|
FACTOR,
|
|
|
|
DIGITS,
|
|
|
|
SYMBOL,
|
|
|
|
ABBREVIATION,
|
|
|
|
SINGULAR,
|
|
|
|
PLURAL,
|
|
|
|
UNIT,
|
|
|
|
USER_UNIT,
|
|
|
|
BG_COLOR,
|
|
|
|
NUM_COLUMNS
|
|
|
|
};
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2004-11-04 23:52:06 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const gchar *title;
|
|
|
|
const gchar *help;
|
|
|
|
|
|
|
|
} UnitColumn;
|
2000-05-02 04:22:55 +08:00
|
|
|
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2004-11-04 23:52:06 +08:00
|
|
|
static void query (void);
|
|
|
|
static void run (const gchar *name,
|
|
|
|
gint n_params,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *n_return_vals,
|
|
|
|
GimpParam **return_vals);
|
|
|
|
|
|
|
|
static GimpUnit new_unit_dialog (GtkWidget *main_dialog,
|
|
|
|
GimpUnit template);
|
|
|
|
static void unit_editor_dialog (void);
|
|
|
|
static void unit_editor_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
gpointer data);
|
|
|
|
static void new_callback (GtkAction *action,
|
|
|
|
GtkTreeView *tv);
|
|
|
|
static void duplicate_callback (GtkAction *action,
|
|
|
|
GtkTreeView *tv);
|
|
|
|
static void saved_toggled_callback (GtkCellRendererToggle *celltoggle,
|
|
|
|
gchar *path_string,
|
|
|
|
GtkListStore *list_store);
|
|
|
|
static void unit_list_init (GtkTreeView *tv);
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2001-08-04 03:52:08 +08:00
|
|
|
|
2006-05-16 20:26:20 +08:00
|
|
|
const GimpPlugInInfo PLUG_IN_INFO =
|
2000-03-01 02:25:05 +08:00
|
|
|
{
|
|
|
|
NULL, /* init_proc */
|
|
|
|
NULL, /* quit_proc */
|
|
|
|
query, /* query_proc */
|
|
|
|
run, /* run_proc */
|
|
|
|
};
|
|
|
|
|
2003-02-11 19:49:33 +08:00
|
|
|
static const UnitColumn columns[] =
|
|
|
|
{
|
|
|
|
{ N_("Saved"), N_("A unit definition will only be saved before "
|
|
|
|
"GIMP exits if this column is checked.") },
|
|
|
|
{ N_("ID"), N_("This string will be used to identify a "
|
|
|
|
"unit in GIMP's configuration files.") },
|
|
|
|
{ N_("Factor"), N_("How many units make up an inch.") },
|
|
|
|
{ N_("Digits"), N_("This field is a hint for numerical input "
|
|
|
|
"fields. It specifies how many decimal digits "
|
|
|
|
"the input field should provide to get "
|
2003-02-20 02:51:17 +08:00
|
|
|
"approximately the same accuracy as an "
|
2003-02-11 19:49:33 +08:00
|
|
|
"\"inch\" input field with two decimal digits.") },
|
2008-11-18 20:49:01 +08:00
|
|
|
{ N_("Symbol"), N_("The unit's symbol if it has one (e.g. \" "
|
2003-02-11 19:49:33 +08:00
|
|
|
"for inches). The unit's abbreviation is used "
|
|
|
|
"if doesn't have a symbol.") },
|
|
|
|
{ N_("Abbreviation"), N_("The unit's abbreviation (e.g. \"cm\" for "
|
|
|
|
"centimeters).") },
|
|
|
|
{ N_("Singular"), N_("The unit's singular form.") },
|
|
|
|
{ N_("Plural"), N_("The unit's plural form.") }
|
2002-11-29 21:57:30 +08:00
|
|
|
};
|
|
|
|
|
2004-11-04 23:52:06 +08:00
|
|
|
static GtkActionEntry actions[] =
|
|
|
|
{
|
|
|
|
{ "unit-editor-toolbar", NULL,
|
|
|
|
"Unit Editor Toolbar", NULL, NULL, NULL
|
|
|
|
},
|
|
|
|
|
2017-03-05 23:01:59 +08:00
|
|
|
{ "unit-editor-new", GIMP_ICON_DOCUMENT_NEW,
|
2005-11-06 05:56:33 +08:00
|
|
|
NULL, "<control>N",
|
2006-03-17 17:29:48 +08:00
|
|
|
N_("Create a new unit from scratch"),
|
2004-11-04 23:52:06 +08:00
|
|
|
G_CALLBACK (new_callback)
|
|
|
|
},
|
|
|
|
|
2017-03-05 23:01:59 +08:00
|
|
|
{ "unit-editor-duplicate", GIMP_ICON_OBJECT_DUPLICATE,
|
2005-11-06 05:56:33 +08:00
|
|
|
NULL, "<control>D",
|
2006-03-17 17:29:48 +08:00
|
|
|
N_("Create a new unit using the currently selected unit as template"),
|
2004-11-04 23:52:06 +08:00
|
|
|
G_CALLBACK (duplicate_callback)
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
MAIN ()
|
|
|
|
|
2002-11-29 21:57:30 +08:00
|
|
|
|
2000-03-01 02:25:05 +08:00
|
|
|
static void
|
|
|
|
query (void)
|
|
|
|
{
|
2006-05-16 20:26:20 +08:00
|
|
|
static const GimpParamDef args[] =
|
2000-03-01 02:25:05 +08:00
|
|
|
{
|
2009-01-20 04:11:36 +08:00
|
|
|
{ GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0) }" }
|
2000-03-01 02:25:05 +08:00
|
|
|
};
|
|
|
|
|
2005-08-16 06:42:34 +08:00
|
|
|
gimp_install_procedure (PLUG_IN_PROC,
|
2006-03-17 17:29:48 +08:00
|
|
|
N_("Create or alter units used in GIMP"),
|
2005-11-06 05:56:33 +08:00
|
|
|
"The GIMP unit editor",
|
2000-03-01 02:25:05 +08:00
|
|
|
"Michael Natterer <mitch@gimp.org>",
|
|
|
|
"Michael Natterer <mitch@gimp.org>",
|
|
|
|
"2000",
|
2008-10-20 14:04:39 +08:00
|
|
|
N_("U_nits"),
|
|
|
|
"",
|
Changed the semantics of GIMP_EXTENSION and (to some extent) of
2003-06-19 Michael Natterer <mitch@gimp.org>
Changed the semantics of GIMP_EXTENSION and (to some extent)
of GIMP_PLUGIN:
The old meaning of EXTENSION was "I live in the toolbox" and
PLUGIN meant "I take RUN-MODE,IMAGE,DRAWABLE args (but only if I
am invoked interactively)". This is completely useless, since
living in the toolbox means having "<Toolbox>" in the menu_path
and taking RUN-MODE,IMAGE,DRAWABLE means just that, regardless of
what type of procedure we are.
The new meaning of GIMP_PLUGIN is just "I am an ordinary procedure,
I am invoked, do my job and finish", while GIMP_EXTENSION means
"I will install temporary procedures and I will keep running to
keep them available".
(A GIMP_EXTENSION *must* call gimp_extension_ack() now to tell the
core that it's ready to run, or the core will block waiting for
the message !!!).
* configure.in: bumped version number to 1.3.16.
* libgimpbase/gimpprotocol.h: increased protocol version number so
old extensions will refuse to load.
* app/gui/plug-in-commands.c (plug_in_run_cmd_callback): don't
blindly pass RUN-MODE,IMAGE,DRAWABLE to GIMP_PLUGIN procedures but
look at their parameters and pass them either RUN-MODE, or
RUN-MODE,IMAGE, or RUN-MODE,IMAGE,DRAWABLE.
* app/pdb/procedural_db.c: cleaned up, better error reporting,
replaced an impossible error message by g_return_if_fail()
* app/plug-in/plug-in-message.c (plug_in_handle_proc_install):
better error messages.
* app/plug-in/plug-in-params.c: allocate parameter arrays using
g_new0() so we don't have to worry about uninitialized stuff
later.
* app/plug-in/plug-in-run.c (plug_in_run): wait for
gimp_extension_ack() installation confirmation for ALL extensions,
not just for automatically started ones.
* app/plug-in/plug-ins.c: cleanup.
* libgimp/gimp.[ch]: cleaned up and API-documented massively. Made
all magic values given in the GPConfig message static and added
accessor functions for them. Added gimp_tile_width()/height().
Added new function gimp_extension_enable() which turns on
asynchronous processing of temp_proc run requests without having
to enter an endless gimp_extension_process() loop. Moved all
private functions to the end of the file. Added tons of
g_return_if_fail() all over the place. Call gimp_run_procedure2()
from gimp_run_procedure() instead of duplicating the
code. Indentation, spacing, stuff...
* libgimp/gimptile.[ch]: removed gimp_tile_width()/height().
* libgimp/gimpdrawable.c
* libgimp/gimppixelrgn.c
* libgimp/gimptile.c: use the gimp_tile_width()/height() accessor
functions.
* libgimp/gimp.def: added gimp_extension_enable.
* libgimp/gimpmenu.c: removed evil code which connected to
_readchannel manually and use gimp_extension_enable() for watching
temp_procs.
* plug-ins/helpbrowser/helpbrowser.c: removed the same evil code
here and call gimp_extension_enable(). Call gimp_extension_ack()
to let the core know that the temp_proc is installed.
* plug-ins/script-fu/script-fu.c: made all procedures except the
permanently running "extension_script_fu" ordinary GIMP_PLUGIN
procedures.
* plug-ins/common/curve_bend.c
* plug-ins/common/plugindetails.c
* plug-ins/common/screenshot.c
* plug-ins/common/uniteditor.c
* plug-ins/common/winclipboard.c
* plug-ins/dbbrowser/dbbrowser.c
* plug-ins/gfli/gfli.c
* plug-ins/twain/twain.c
* plug-ins/webbrowser/webbrowser.c
* plug-ins/winsnap/winsnap.c: made them all ordinary GIMP_PLUGIN
procedures and renamed them from "extension_*" to "plug_in_*".
Random cleanups.
* app/widgets/gimphelp.c
* plug-ins/maze/maze_face.c: call "plug_in_web_browser" now.
2003-06-20 01:12:00 +08:00
|
|
|
GIMP_PLUGIN,
|
2008-10-20 14:04:39 +08:00
|
|
|
G_N_ELEMENTS (args), 0,
|
2000-03-01 02:25:05 +08:00
|
|
|
args, NULL);
|
2004-05-07 21:15:52 +08:00
|
|
|
|
2007-09-20 19:39:32 +08:00
|
|
|
gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Edit/Preferences");
|
2014-05-12 05:56:30 +08:00
|
|
|
gimp_plugin_icon_register (PLUG_IN_PROC, GIMP_ICON_TYPE_ICON_NAME,
|
2017-03-05 23:01:59 +08:00
|
|
|
(const guint8 *) GIMP_ICON_TOOL_MEASURE);
|
2000-03-01 02:25:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-07-02 21:00:16 +08:00
|
|
|
run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals)
|
2000-03-01 02:25:05 +08:00
|
|
|
{
|
2002-01-08 17:20:02 +08:00
|
|
|
static GimpParam values[2];
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
INIT_I18N ();
|
|
|
|
|
2000-03-01 02:25:05 +08:00
|
|
|
*nreturn_vals = 1;
|
|
|
|
*return_vals = values;
|
2001-11-28 09:14:06 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
|
|
|
values[0].data.d_status = GIMP_PDB_CALLING_ERROR;
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2005-08-16 06:42:34 +08:00
|
|
|
if (strcmp (name, PLUG_IN_PROC) == 0)
|
2000-03-01 02:25:05 +08:00
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
values[0].data.d_status = GIMP_PDB_SUCCESS;
|
2000-03-01 02:25:05 +08:00
|
|
|
|
|
|
|
unit_editor_dialog ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GimpUnit
|
2004-11-04 23:52:06 +08:00
|
|
|
new_unit_dialog (GtkWidget *main_dialog,
|
|
|
|
GimpUnit template)
|
2000-03-01 02:25:05 +08:00
|
|
|
{
|
2014-06-23 05:01:31 +08:00
|
|
|
GtkWidget *dialog;
|
2018-05-11 18:30:03 +08:00
|
|
|
GtkWidget *grid;
|
2014-06-23 05:01:31 +08:00
|
|
|
GtkWidget *entry;
|
|
|
|
GtkWidget *spinbutton;
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2014-06-23 05:01:31 +08:00
|
|
|
GtkWidget *identifier_entry;
|
|
|
|
GtkAdjustment *factor_adj;
|
|
|
|
GtkAdjustment *digits_adj;
|
|
|
|
GtkWidget *symbol_entry;
|
|
|
|
GtkWidget *abbreviation_entry;
|
|
|
|
GtkWidget *singular_entry;
|
|
|
|
GtkWidget *plural_entry;
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2014-06-23 05:01:31 +08:00
|
|
|
GimpUnit unit = GIMP_UNIT_PIXEL;
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2011-04-09 02:31:34 +08:00
|
|
|
dialog = gimp_dialog_new (_("Add a New Unit"), PLUG_IN_ROLE,
|
2003-11-06 23:27:05 +08:00
|
|
|
main_dialog, GTK_DIALOG_MODAL,
|
2008-10-20 14:04:39 +08:00
|
|
|
gimp_standard_help_func, PLUG_IN_PROC,
|
2001-12-31 09:22:47 +08:00
|
|
|
|
2017-02-12 23:18:24 +08:00
|
|
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
|
|
|
_("_Add"), GTK_RESPONSE_OK,
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
NULL);
|
2002-11-29 21:57:30 +08:00
|
|
|
|
2018-05-10 23:04:37 +08:00
|
|
|
gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
2005-08-16 06:42:34 +08:00
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
2005-02-09 04:40:33 +08:00
|
|
|
|
2018-05-11 18:30:03 +08:00
|
|
|
grid = gtk_grid_new ();
|
|
|
|
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
|
|
|
|
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (grid), 12);
|
2009-07-16 00:57:12 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
|
2018-05-11 18:30:03 +08:00
|
|
|
grid, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (grid);
|
2000-03-01 02:25:05 +08:00
|
|
|
|
|
|
|
entry = identifier_entry = gtk_entry_new ();
|
|
|
|
if (template != GIMP_UNIT_PIXEL)
|
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry),
|
2001-12-31 09:22:47 +08:00
|
|
|
gimp_unit_get_identifier (template));
|
2000-03-01 02:25:05 +08:00
|
|
|
}
|
2018-05-11 18:30:03 +08:00
|
|
|
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 0,
|
|
|
|
_("_ID:"), 0.0, 0.5,
|
|
|
|
entry, 1);
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2003-02-11 19:49:33 +08:00
|
|
|
gimp_help_set_help_data (entry, gettext (columns[IDENTIFIER].help), NULL);
|
2000-03-04 08:24:39 +08:00
|
|
|
|
2018-06-25 00:15:16 +08:00
|
|
|
factor_adj = gtk_adjustment_new ((template != GIMP_UNIT_PIXEL) ?
|
|
|
|
gimp_unit_get_factor (template) : 1.0,
|
|
|
|
GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION,
|
|
|
|
0.01, 0.1, 0.0);
|
2014-06-23 05:01:31 +08:00
|
|
|
spinbutton = gtk_spin_button_new (factor_adj, 0.01, 5);
|
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
2018-05-11 18:30:03 +08:00
|
|
|
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 1,
|
|
|
|
_("_Factor:"), 0.0, 0.5,
|
|
|
|
spinbutton, 1);
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2003-02-11 19:49:33 +08:00
|
|
|
gimp_help_set_help_data (spinbutton, gettext (columns[FACTOR].help), NULL);
|
2000-03-04 08:24:39 +08:00
|
|
|
|
2018-06-25 00:15:16 +08:00
|
|
|
digits_adj = gtk_adjustment_new ((template != GIMP_UNIT_PIXEL) ?
|
|
|
|
gimp_unit_get_digits (template) : 2.0,
|
|
|
|
0, 5, 1, 1, 0);
|
2014-06-23 05:01:31 +08:00
|
|
|
spinbutton = gtk_spin_button_new (digits_adj, 0, 0);
|
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
2018-05-11 18:30:03 +08:00
|
|
|
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 2,
|
|
|
|
_("_Digits:"), 0.0, 0.5,
|
|
|
|
spinbutton, 1);
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2003-02-11 19:49:33 +08:00
|
|
|
gimp_help_set_help_data (spinbutton, gettext (columns[DIGITS].help), NULL);
|
2000-03-04 08:24:39 +08:00
|
|
|
|
2000-03-01 02:25:05 +08:00
|
|
|
entry = symbol_entry = gtk_entry_new ();
|
|
|
|
if (template != GIMP_UNIT_PIXEL)
|
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry),
|
2001-12-31 09:22:47 +08:00
|
|
|
gimp_unit_get_symbol (template));
|
2000-03-01 02:25:05 +08:00
|
|
|
}
|
2018-05-11 18:30:03 +08:00
|
|
|
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 3,
|
|
|
|
_("_Symbol:"), 0.0, 0.5,
|
|
|
|
entry, 1);
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2003-02-11 19:49:33 +08:00
|
|
|
gimp_help_set_help_data (entry, gettext (columns[SYMBOL].help), NULL);
|
2000-03-04 08:24:39 +08:00
|
|
|
|
2000-03-01 02:25:05 +08:00
|
|
|
entry = abbreviation_entry = gtk_entry_new ();
|
|
|
|
if (template != GIMP_UNIT_PIXEL)
|
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry),
|
2001-12-31 09:22:47 +08:00
|
|
|
gimp_unit_get_abbreviation (template));
|
2000-03-01 02:25:05 +08:00
|
|
|
}
|
2018-05-11 18:30:03 +08:00
|
|
|
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 4,
|
|
|
|
_("_Abbreviation:"), 0.0, 0.5,
|
|
|
|
entry, 1);
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2003-02-11 19:49:33 +08:00
|
|
|
gimp_help_set_help_data (entry, gettext (columns[ABBREVIATION].help), NULL);
|
2000-03-04 08:24:39 +08:00
|
|
|
|
2000-03-01 02:25:05 +08:00
|
|
|
entry = singular_entry = gtk_entry_new ();
|
|
|
|
if (template != GIMP_UNIT_PIXEL)
|
|
|
|
{
|
2001-12-31 09:22:47 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry),
|
|
|
|
gimp_unit_get_singular (template));
|
2000-03-01 02:25:05 +08:00
|
|
|
}
|
2018-05-11 18:30:03 +08:00
|
|
|
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 5,
|
|
|
|
_("Si_ngular:"), 0.0, 0.5,
|
|
|
|
entry, 1);
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2003-02-11 19:49:33 +08:00
|
|
|
gimp_help_set_help_data (entry, gettext (columns[SINGULAR].help), NULL);
|
2000-03-04 08:24:39 +08:00
|
|
|
|
2000-03-01 02:25:05 +08:00
|
|
|
entry = plural_entry = gtk_entry_new ();
|
|
|
|
if (template != GIMP_UNIT_PIXEL)
|
|
|
|
{
|
2001-12-31 09:22:47 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry),
|
|
|
|
gimp_unit_get_plural (template));
|
2000-03-01 02:25:05 +08:00
|
|
|
}
|
2018-05-11 18:30:03 +08:00
|
|
|
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 6,
|
|
|
|
_("_Plural:"), 0.0, 0.5,
|
|
|
|
entry, 1);
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2003-02-11 19:49:33 +08:00
|
|
|
gimp_help_set_help_data (entry, gettext (columns[PLURAL].help), NULL);
|
2000-03-04 08:24:39 +08:00
|
|
|
|
2000-03-01 02:25:05 +08:00
|
|
|
gtk_widget_show (dialog);
|
|
|
|
|
2001-08-30 01:48:28 +08:00
|
|
|
while (TRUE)
|
2000-03-01 02:25:05 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
gchar *identifier;
|
|
|
|
gdouble factor;
|
|
|
|
gint digits;
|
|
|
|
gchar *symbol;
|
|
|
|
gchar *abbreviation;
|
|
|
|
gchar *singular;
|
|
|
|
gchar *plural;
|
|
|
|
|
2003-11-12 02:11:56 +08:00
|
|
|
if (gimp_dialog_run (GIMP_DIALOG (dialog)) != GTK_RESPONSE_OK)
|
2003-11-06 23:27:05 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
identifier = g_strdup (gtk_entry_get_text (GTK_ENTRY (identifier_entry)));
|
2010-10-25 07:26:00 +08:00
|
|
|
factor = gtk_adjustment_get_value (factor_adj);
|
|
|
|
digits = gtk_adjustment_get_value (digits_adj);
|
2003-11-06 23:27:05 +08:00
|
|
|
symbol = g_strdup (gtk_entry_get_text (GTK_ENTRY (symbol_entry)));
|
|
|
|
abbreviation = g_strdup (gtk_entry_get_text (GTK_ENTRY (abbreviation_entry)));
|
|
|
|
singular = g_strdup (gtk_entry_get_text (GTK_ENTRY (singular_entry)));
|
|
|
|
plural = g_strdup (gtk_entry_get_text (GTK_ENTRY (plural_entry)));
|
|
|
|
|
|
|
|
identifier = g_strstrip (identifier);
|
|
|
|
symbol = g_strstrip (symbol);
|
|
|
|
abbreviation = g_strstrip (abbreviation);
|
|
|
|
singular = g_strstrip (singular);
|
|
|
|
plural = g_strstrip (plural);
|
|
|
|
|
2018-04-28 08:48:56 +08:00
|
|
|
if (! strlen (identifier) ||
|
|
|
|
! strlen (symbol) ||
|
|
|
|
! strlen (abbreviation) ||
|
|
|
|
! strlen (singular) ||
|
|
|
|
! strlen (plural))
|
2003-11-06 23:27:05 +08:00
|
|
|
{
|
2005-11-06 05:56:33 +08:00
|
|
|
GtkWidget *msg = gtk_message_dialog_new (GTK_WINDOW (dialog), 0,
|
|
|
|
GTK_MESSAGE_ERROR,
|
|
|
|
GTK_BUTTONS_OK,
|
|
|
|
_("Incomplete input"));
|
|
|
|
|
|
|
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (msg),
|
|
|
|
_("Please fill in all text fields."));
|
|
|
|
gtk_dialog_run (GTK_DIALOG (msg));
|
|
|
|
gtk_widget_destroy (msg);
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-11-06 05:56:33 +08:00
|
|
|
unit = gimp_unit_new (identifier,
|
|
|
|
factor, digits,
|
|
|
|
symbol, abbreviation, singular, plural);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
|
|
|
g_free (identifier);
|
|
|
|
g_free (symbol);
|
|
|
|
g_free (abbreviation);
|
|
|
|
g_free (singular);
|
|
|
|
g_free (plural);
|
|
|
|
|
|
|
|
break;
|
2000-03-01 02:25:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
|
|
|
return unit;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-11-04 23:52:06 +08:00
|
|
|
unit_editor_dialog (void)
|
2000-03-01 02:25:05 +08:00
|
|
|
{
|
2005-11-06 05:56:33 +08:00
|
|
|
GtkWidget *dialog;
|
2004-11-04 23:52:06 +08:00
|
|
|
GtkWidget *scrolled_win;
|
|
|
|
GtkUIManager *ui_manager;
|
|
|
|
GtkActionGroup *group;
|
|
|
|
GtkWidget *toolbar;
|
|
|
|
GtkListStore *list_store;
|
|
|
|
GtkWidget *tv;
|
|
|
|
GtkTreeViewColumn *col;
|
2009-10-10 21:10:14 +08:00
|
|
|
GtkWidget *col_widget;
|
|
|
|
GtkWidget *button;
|
2004-11-04 23:52:06 +08:00
|
|
|
GtkCellRenderer *rend;
|
|
|
|
gint i;
|
2002-11-29 21:57:30 +08:00
|
|
|
|
2005-08-16 06:42:34 +08:00
|
|
|
gimp_ui_init (PLUG_IN_BINARY, FALSE);
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2004-11-04 23:52:06 +08:00
|
|
|
list_store = gtk_list_store_new (NUM_COLUMNS,
|
|
|
|
G_TYPE_BOOLEAN, /* SAVE */
|
|
|
|
G_TYPE_STRING, /* IDENTIFIER */
|
|
|
|
G_TYPE_DOUBLE, /* FACTOR */
|
|
|
|
G_TYPE_INT, /* DIGITS */
|
|
|
|
G_TYPE_STRING, /* SYMBOL */
|
|
|
|
G_TYPE_STRING, /* ABBREVIATION */
|
|
|
|
G_TYPE_STRING, /* SINGULAR */
|
|
|
|
G_TYPE_STRING, /* PLURAL */
|
|
|
|
GIMP_TYPE_UNIT, /* UNIT */
|
|
|
|
G_TYPE_BOOLEAN, /* USER_UNIT */
|
|
|
|
GDK_TYPE_COLOR); /* BG_COLOR */
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2004-11-04 23:52:06 +08:00
|
|
|
tv = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
|
|
|
|
g_object_unref (list_store);
|
2002-11-29 21:57:30 +08:00
|
|
|
|
2011-04-09 02:31:34 +08:00
|
|
|
dialog = gimp_dialog_new (_("Unit Editor"), PLUG_IN_ROLE,
|
2005-11-06 05:56:33 +08:00
|
|
|
NULL, 0,
|
|
|
|
gimp_standard_help_func, PLUG_IN_PROC,
|
2002-11-29 21:57:30 +08:00
|
|
|
|
2017-02-12 23:18:24 +08:00
|
|
|
_("_Refresh"), RESPONSE_REFRESH,
|
|
|
|
_("_Close"), GTK_RESPONSE_CLOSE,
|
2002-11-29 21:57:30 +08:00
|
|
|
|
2005-11-06 05:56:33 +08:00
|
|
|
NULL);
|
2002-11-29 21:57:30 +08:00
|
|
|
|
2005-11-06 05:56:33 +08:00
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
|
2002-11-29 21:57:30 +08:00
|
|
|
|
2005-11-06 05:56:33 +08:00
|
|
|
g_signal_connect (dialog, "response",
|
2004-11-04 23:52:06 +08:00
|
|
|
G_CALLBACK (unit_editor_response),
|
|
|
|
tv);
|
2005-11-06 05:56:33 +08:00
|
|
|
g_signal_connect (dialog, "destroy",
|
2004-11-04 23:52:06 +08:00
|
|
|
G_CALLBACK (gtk_main_quit),
|
|
|
|
NULL);
|
2002-11-29 21:57:30 +08:00
|
|
|
|
2004-11-04 23:52:06 +08:00
|
|
|
/* the toolbar */
|
|
|
|
ui_manager = gtk_ui_manager_new ();
|
|
|
|
|
|
|
|
group = gtk_action_group_new ("unit-editor");
|
2005-11-06 05:56:33 +08:00
|
|
|
|
2004-11-04 23:58:49 +08:00
|
|
|
gtk_action_group_set_translation_domain (group, NULL);
|
2004-11-04 23:52:06 +08:00
|
|
|
gtk_action_group_add_actions (group, actions, G_N_ELEMENTS (actions), tv);
|
|
|
|
|
2005-11-06 05:56:33 +08:00
|
|
|
gtk_window_add_accel_group (GTK_WINDOW (dialog),
|
|
|
|
gtk_ui_manager_get_accel_group (ui_manager));
|
|
|
|
gtk_accel_group_lock (gtk_ui_manager_get_accel_group (ui_manager));
|
|
|
|
|
2004-11-04 23:52:06 +08:00
|
|
|
gtk_ui_manager_insert_action_group (ui_manager, group, -1);
|
|
|
|
g_object_unref (group);
|
|
|
|
|
|
|
|
gtk_ui_manager_add_ui_from_string
|
|
|
|
(ui_manager,
|
|
|
|
"<ui>\n"
|
|
|
|
" <toolbar action=\"unit-editor-toolbar\">\n"
|
|
|
|
" <toolitem action=\"unit-editor-new\" />\n"
|
|
|
|
" <toolitem action=\"unit-editor-duplicate\" />\n"
|
|
|
|
" </toolbar>\n"
|
|
|
|
"</ui>\n",
|
|
|
|
-1, NULL);
|
|
|
|
|
|
|
|
toolbar = gtk_ui_manager_get_widget (ui_manager, "/unit-editor-toolbar");
|
2009-07-16 00:57:12 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
|
|
|
|
toolbar, FALSE, FALSE, 0);
|
2004-11-04 23:52:06 +08:00
|
|
|
gtk_widget_show (toolbar);
|
|
|
|
|
|
|
|
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
|
2019-01-05 21:15:01 +08:00
|
|
|
gtk_widget_set_size_request (scrolled_win, -1, 200);
|
2004-11-04 23:52:06 +08:00
|
|
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
|
2008-10-20 14:04:39 +08:00
|
|
|
GTK_SHADOW_IN);
|
2004-11-04 23:52:06 +08:00
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
|
|
|
|
GTK_POLICY_NEVER,
|
|
|
|
GTK_POLICY_ALWAYS);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (scrolled_win), 12);
|
2011-03-04 17:44:58 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
|
|
|
|
scrolled_win, TRUE, TRUE, 0);
|
2004-11-04 23:52:06 +08:00
|
|
|
gtk_widget_show (scrolled_win);
|
|
|
|
|
|
|
|
gtk_widget_set_size_request (tv, -1, 220);
|
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled_win), tv);
|
|
|
|
gtk_widget_show (tv);
|
|
|
|
|
|
|
|
rend = gtk_cell_renderer_toggle_new ();
|
|
|
|
col =
|
|
|
|
gtk_tree_view_column_new_with_attributes (gettext (columns[SAVE].title),
|
|
|
|
rend,
|
|
|
|
"active", SAVE,
|
|
|
|
"activatable", USER_UNIT,
|
|
|
|
"cell-background-gdk", BG_COLOR,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gtk_tree_view_append_column (GTK_TREE_VIEW (tv), col);
|
|
|
|
|
2009-10-10 21:10:14 +08:00
|
|
|
col_widget = gtk_tree_view_column_get_widget (col);
|
|
|
|
if (col_widget)
|
|
|
|
{
|
|
|
|
button = gtk_widget_get_ancestor (col_widget, GTK_TYPE_BUTTON);
|
|
|
|
|
|
|
|
if (button)
|
|
|
|
gimp_help_set_help_data (button,
|
|
|
|
gettext (columns[SAVE].help), NULL);
|
|
|
|
}
|
2004-11-04 23:52:06 +08:00
|
|
|
|
|
|
|
g_signal_connect (rend, "toggled",
|
|
|
|
G_CALLBACK (saved_toggled_callback),
|
|
|
|
list_store);
|
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (columns); i++)
|
|
|
|
{
|
|
|
|
if (i == SAVE)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
col =
|
|
|
|
gtk_tree_view_column_new_with_attributes (gettext (columns[i].title),
|
|
|
|
gtk_cell_renderer_text_new (),
|
|
|
|
"text", i,
|
|
|
|
"cell-background-gdk", BG_COLOR,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gtk_tree_view_append_column (GTK_TREE_VIEW (tv), col);
|
|
|
|
|
2009-10-10 21:10:14 +08:00
|
|
|
col_widget = gtk_tree_view_column_get_widget (col);
|
|
|
|
if (col_widget)
|
|
|
|
{
|
|
|
|
button = gtk_widget_get_ancestor (col_widget, GTK_TYPE_BUTTON);
|
|
|
|
|
|
|
|
if (button)
|
|
|
|
gimp_help_set_help_data (button, gettext (columns[i].help), NULL);
|
|
|
|
}
|
2002-11-29 21:57:30 +08:00
|
|
|
}
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2004-11-04 23:52:06 +08:00
|
|
|
unit_list_init (GTK_TREE_VIEW (tv));
|
|
|
|
|
2005-11-06 05:56:33 +08:00
|
|
|
gtk_widget_show (dialog);
|
2004-11-04 23:52:06 +08:00
|
|
|
|
|
|
|
gtk_main ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
unit_editor_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
switch (response_id)
|
|
|
|
{
|
|
|
|
case RESPONSE_REFRESH:
|
|
|
|
unit_list_init (GTK_TREE_VIEW (data));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
gtk_widget_destroy (widget);
|
|
|
|
break;
|
|
|
|
}
|
2002-11-29 21:57:30 +08:00
|
|
|
}
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2002-11-29 21:57:30 +08:00
|
|
|
static void
|
2004-11-04 23:52:06 +08:00
|
|
|
new_callback (GtkAction *action,
|
2008-10-20 14:04:39 +08:00
|
|
|
GtkTreeView *tv)
|
2002-11-29 21:57:30 +08:00
|
|
|
{
|
2003-02-25 22:48:24 +08:00
|
|
|
GimpUnit unit;
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2004-11-04 23:52:06 +08:00
|
|
|
unit = new_unit_dialog (gtk_widget_get_toplevel (GTK_WIDGET (tv)),
|
|
|
|
GIMP_UNIT_PIXEL);
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2002-11-29 21:57:30 +08:00
|
|
|
if (unit != GIMP_UNIT_PIXEL)
|
2000-03-01 02:25:05 +08:00
|
|
|
{
|
2003-02-25 22:48:24 +08:00
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
2002-11-29 21:57:30 +08:00
|
|
|
|
2004-11-04 23:52:06 +08:00
|
|
|
unit_list_init (tv);
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2003-02-25 22:48:24 +08:00
|
|
|
model = gtk_tree_view_get_model (tv);
|
|
|
|
|
2004-11-04 18:06:22 +08:00
|
|
|
if (gtk_tree_model_get_iter_first (model, &iter) &&
|
2003-02-25 22:48:24 +08:00
|
|
|
gtk_tree_model_iter_nth_child (model, &iter,
|
2002-11-29 21:57:30 +08:00
|
|
|
NULL, unit - GIMP_UNIT_INCH))
|
|
|
|
{
|
|
|
|
GtkAdjustment *adj;
|
|
|
|
|
2003-02-25 22:48:24 +08:00
|
|
|
gtk_tree_selection_select_iter (gtk_tree_view_get_selection (tv),
|
|
|
|
&iter);
|
2002-11-29 21:57:30 +08:00
|
|
|
|
2010-11-05 23:39:22 +08:00
|
|
|
adj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (tv));
|
2009-10-10 21:10:14 +08:00
|
|
|
gtk_adjustment_set_value (adj, gtk_adjustment_get_upper (adj));
|
2002-11-29 21:57:30 +08:00
|
|
|
}
|
2000-03-01 02:25:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-11-04 23:52:06 +08:00
|
|
|
duplicate_callback (GtkAction *action,
|
2008-10-20 14:04:39 +08:00
|
|
|
GtkTreeView *tv)
|
2000-03-01 02:25:05 +08:00
|
|
|
{
|
2003-02-25 22:48:24 +08:00
|
|
|
GtkTreeModel *model;
|
2002-11-29 21:57:30 +08:00
|
|
|
GtkTreeSelection *sel;
|
|
|
|
GtkTreeIter iter;
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2003-02-25 22:48:24 +08:00
|
|
|
model = gtk_tree_view_get_model (tv);
|
|
|
|
sel = gtk_tree_view_get_selection (tv);
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2002-11-29 21:57:30 +08:00
|
|
|
if (gtk_tree_selection_get_selected (sel, NULL, &iter))
|
2000-03-01 02:25:05 +08:00
|
|
|
{
|
2002-11-29 21:57:30 +08:00
|
|
|
GimpUnit unit;
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2003-02-25 22:48:24 +08:00
|
|
|
gtk_tree_model_get (model, &iter,
|
2002-11-29 21:57:30 +08:00
|
|
|
UNIT, &unit,
|
|
|
|
-1);
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2004-11-04 23:52:06 +08:00
|
|
|
unit = new_unit_dialog (gtk_widget_get_toplevel (GTK_WIDGET (tv)),
|
|
|
|
unit);
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2002-11-29 21:57:30 +08:00
|
|
|
if (unit != GIMP_UNIT_PIXEL)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2004-11-04 23:52:06 +08:00
|
|
|
unit_list_init (tv);
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2004-11-04 18:06:22 +08:00
|
|
|
if (gtk_tree_model_get_iter_first (model, &iter) &&
|
2003-02-25 22:48:24 +08:00
|
|
|
gtk_tree_model_iter_nth_child (model, &iter,
|
2002-11-29 21:57:30 +08:00
|
|
|
NULL, unit - GIMP_UNIT_INCH))
|
|
|
|
{
|
|
|
|
GtkAdjustment *adj;
|
|
|
|
|
|
|
|
gtk_tree_selection_select_iter (sel, &iter);
|
|
|
|
|
2010-11-05 23:39:22 +08:00
|
|
|
adj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (tv));
|
2009-10-10 21:10:14 +08:00
|
|
|
gtk_adjustment_set_value (adj, gtk_adjustment_get_upper (adj));
|
2002-11-29 21:57:30 +08:00
|
|
|
}
|
|
|
|
}
|
2000-03-01 02:25:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-11-29 21:57:30 +08:00
|
|
|
saved_toggled_callback (GtkCellRendererToggle *celltoggle,
|
|
|
|
gchar *path_string,
|
|
|
|
GtkListStore *list_store)
|
2000-03-01 02:25:05 +08:00
|
|
|
{
|
2002-11-29 21:57:30 +08:00
|
|
|
GtkTreePath *path;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gboolean saved;
|
|
|
|
GimpUnit unit;
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2002-11-29 21:57:30 +08:00
|
|
|
path = gtk_tree_path_new_from_string (path_string);
|
2005-11-06 05:56:33 +08:00
|
|
|
|
2002-11-29 21:57:30 +08:00
|
|
|
if (! gtk_tree_model_get_iter (GTK_TREE_MODEL (list_store), &iter, path))
|
2000-03-01 02:25:05 +08:00
|
|
|
{
|
2002-11-29 21:57:30 +08:00
|
|
|
g_warning ("%s: bad tree path?", G_STRLOC);
|
|
|
|
return;
|
2000-03-01 02:25:05 +08:00
|
|
|
}
|
2002-11-29 21:57:30 +08:00
|
|
|
gtk_tree_path_free (path);
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2002-11-29 21:57:30 +08:00
|
|
|
gtk_tree_model_get (GTK_TREE_MODEL (list_store), &iter,
|
|
|
|
SAVE, &saved,
|
|
|
|
UNIT, &unit,
|
|
|
|
-1);
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2002-11-29 21:57:30 +08:00
|
|
|
if (unit >= gimp_unit_get_number_of_built_in_units ())
|
|
|
|
{
|
|
|
|
gimp_unit_set_deletion_flag (unit, saved);
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (list_store), &iter,
|
|
|
|
SAVE, ! saved,
|
|
|
|
-1);
|
|
|
|
}
|
2000-03-01 02:25:05 +08:00
|
|
|
}
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
static void
|
2004-11-04 23:52:06 +08:00
|
|
|
unit_list_init (GtkTreeView *tv)
|
2000-03-01 02:25:05 +08:00
|
|
|
{
|
2004-11-04 23:52:06 +08:00
|
|
|
GtkListStore *list_store;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gint num_units;
|
|
|
|
GimpUnit unit;
|
|
|
|
GdkColor color;
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2004-11-04 23:52:06 +08:00
|
|
|
list_store = GTK_LIST_STORE (gtk_tree_view_get_model (tv));
|
2003-02-11 19:49:33 +08:00
|
|
|
|
2004-11-04 23:52:06 +08:00
|
|
|
gtk_list_store_clear (list_store);
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2004-11-04 23:52:06 +08:00
|
|
|
num_units = gimp_unit_get_number_of_units ();
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2004-11-04 23:52:06 +08:00
|
|
|
color.red = 0xdddd;
|
|
|
|
color.green = 0xdddd;
|
|
|
|
color.blue = 0xffff;
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2004-11-04 23:52:06 +08:00
|
|
|
for (unit = GIMP_UNIT_INCH; unit < num_units; unit++)
|
2003-02-11 19:49:33 +08:00
|
|
|
{
|
2005-11-06 05:56:33 +08:00
|
|
|
gboolean user_unit = (unit >= gimp_unit_get_number_of_built_in_units ());
|
2002-11-29 21:57:30 +08:00
|
|
|
|
2004-11-04 23:52:06 +08:00
|
|
|
gtk_list_store_append (list_store, &iter);
|
|
|
|
gtk_list_store_set (list_store, &iter,
|
|
|
|
SAVE, ! gimp_unit_get_deletion_flag (unit),
|
|
|
|
IDENTIFIER, gimp_unit_get_identifier (unit),
|
|
|
|
FACTOR, gimp_unit_get_factor (unit),
|
|
|
|
DIGITS, gimp_unit_get_digits (unit),
|
|
|
|
SYMBOL, gimp_unit_get_symbol (unit),
|
|
|
|
ABBREVIATION, gimp_unit_get_abbreviation (unit),
|
|
|
|
SINGULAR, gimp_unit_get_singular (unit),
|
|
|
|
PLURAL, gimp_unit_get_plural (unit),
|
|
|
|
UNIT, unit,
|
|
|
|
USER_UNIT, user_unit,
|
2002-11-29 21:57:30 +08:00
|
|
|
|
2004-11-04 23:52:06 +08:00
|
|
|
user_unit ? -1 : BG_COLOR, &color,
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2004-11-04 23:52:06 +08:00
|
|
|
-1);
|
|
|
|
}
|
2000-03-01 02:25:05 +08:00
|
|
|
|
2004-11-04 23:52:06 +08:00
|
|
|
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (list_store), &iter))
|
|
|
|
gtk_tree_selection_select_iter (gtk_tree_view_get_selection (tv), &iter);
|
2000-03-01 02:25:05 +08:00
|
|
|
}
|