Commit 278a6991 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

bind the "gimp-libgimp" textdomain to get the libgimp widget translations.

2000-01-28  Michael Natterer  <mitch@gimp.org>

	* app/main.c: bind the "gimp-libgimp" textdomain to get the
	libgimp widget translations. Did some code cleanup.

	* libgimp/stdplugins-intl.h: bind "gimp-libgimp".

	* libgimp/gimpintl.h: copyright header.

	* libgimp/libgimp-intl.h: there is no dgettext_noop() function
	(typo/braino).

	* libgimp/gimpwidgets.[ch]: one more table attach helper
	function. Should probably find a general way for the two
	functions.

	* plug-ins/common/CML_explorer.c
	* plug-ins/common/align_layers.c
	* plug-ins/common/scatter_hsv.c
	* plug-ins/common/threshold_alpha.c: removed the gtkW_* wrapper
	functions. Badly hacked CML_explorer (The optionmenu creation is a
	bit more ugly than before but at least consistent with the other
	files using the libgimp optionmenu constructor).
parent b6c9232f
2000-01-28 Michael Natterer <mitch@gimp.org>
* app/main.c: bind the "gimp-libgimp" textdomain to get the
libgimp widget translations. Did some code cleanup.
* libgimp/stdplugins-intl.h: bind "gimp-libgimp".
* libgimp/gimpintl.h: copyright header.
* libgimp/libgimp-intl.h: there is no dgettext_noop() function
(typo/braino).
* libgimp/gimpwidgets.[ch]: one more table attach helper
function. Should probably find a general way for the two
functions.
* plug-ins/common/CML_explorer.c
* plug-ins/common/align_layers.c
* plug-ins/common/scatter_hsv.c
* plug-ins/common/threshold_alpha.c: removed the gtkW_* wrapper
functions. Badly hacked CML_explorer (The optionmenu creation is a
bit more ugly than before but at least consistent with the other
files using the libgimp optionmenu constructor).
2000-01-28 Asbjorn Pettersen <asbjornP@dualog.no>
* plug-ins/print/print-ps.c: use g_strcasecmp() instead of
......
......@@ -17,7 +17,6 @@
*/
#include "config.h"
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
......@@ -49,36 +48,37 @@
#ifdef G_OS_WIN32
#include <windows.h>
#else
static RETSIGTYPE on_signal (int);
static RETSIGTYPE on_signal (gint);
#ifdef SIGCHLD
static RETSIGTYPE on_sig_child (int);
static RETSIGTYPE on_sig_child (gint);
#endif
#endif
static void init (void);
static void test_gserialize();
static void on_error (const gchar* domain,
GLogLevelFlags flags,
const gchar* msg,
gpointer user_data);
static void init (void);
static void test_gserialize (void);
static void on_error (const gchar *domain,
GLogLevelFlags flags,
const gchar *msg,
gpointer user_data);
/* GLOBAL data */
int no_interface;
int no_data;
int no_splash;
int no_splash_image;
int be_verbose;
int use_shm;
int use_debug_handler;
int console_messages;
int restore_session;
GimpSet* image_context;
MessageHandlerType message_handler;
gchar *prog_name; /* The path name we are invoked with */
gchar *alternate_gimprc;
gchar *alternate_system_gimprc;
gchar **batch_cmds;
gint no_interface = FALSE;
gint no_data = FALSE;
gint no_splash = FALSE;
gint no_splash_image = FALSE;
gint be_verbose = FALSE;
gint use_shm = FALSE;
gint use_debug_handler = FALSE;
gint console_messages = FALSE;
gint restore_session = FALSE;
GimpSet *image_context = NULL;
MessageHandlerType message_handler = CONSOLE;
gchar *prog_name = NULL; /* The path name we are invoked with */
gchar *alternate_gimprc = NULL;
gchar *alternate_system_gimprc = NULL;
gchar **batch_cmds = NULL;
#ifdef ENABLE_NLS
gchar *plugin_domains[] = { "gimp-std-plugins",
......@@ -88,8 +88,8 @@ gint n_plugin_domains = (sizeof (plugin_domains) /
#endif
/* LOCAL data */
static gint gimp_argc;
static gchar **gimp_argv;
static gint gimp_argc = 0;
static gchar **gimp_argv = NULL;
/*
* argv processing:
......@@ -113,25 +113,28 @@ static gchar **gimp_argv;
*/
int
main (int argc, char **argv)
main (int argc,
char **argv)
{
int show_version;
int show_help;
int i, j;
gint show_version = FALSE;
gint show_help = FALSE;
gint i, j;
#ifdef HAVE_PUTENV
gchar *display_name, *display_env;
gchar *display_env;
#endif
g_atexit (g_mem_profile);
/* Initialize variables */
prog_name = argv[0];
/* Initialize i18n support */
INIT_LOCALE ("gimp");
#ifdef ENABLE_NLS
bindtextdomain ("gimp-libgimp", LOCALEDIR);
for (i = 0; i < n_plugin_domains; i++)
bindtextdomain (plugin_domains[i], LOCALEDIR);
#endif
......@@ -141,39 +144,16 @@ main (int argc, char **argv)
setlocale (LC_NUMERIC, "C"); /* gtk seems to zap this during init.. */
#ifdef HAVE_PUTENV
display_name = gdk_get_display ();
display_env = g_new (gchar, strlen (display_name) + 9);
*display_env = 0;
strcat (display_env, "DISPLAY=");
strcat (display_env, display_name);
display_env = g_strconcat ("DISPLAY=", gdk_get_display (), NULL);
putenv (display_env);
#endif
no_interface = FALSE;
no_data = FALSE;
no_splash = FALSE;
no_splash_image = FALSE;
#if defined (HAVE_SHM_H) || defined (G_OS_WIN32)
use_shm = TRUE;
#else
use_shm = FALSE;
#endif
use_debug_handler = FALSE;
restore_session = FALSE;
console_messages = FALSE;
message_handler = CONSOLE;
batch_cmds = g_new (char *, argc);
batch_cmds = g_new (char *, argc);
batch_cmds[0] = NULL;
alternate_gimprc = NULL;
alternate_system_gimprc = NULL;
show_version = FALSE;
show_help = FALSE;
test_gserialize ();
......@@ -278,9 +258,9 @@ main (int argc, char **argv)
restore_session = TRUE;
argv[i] = NULL;
}
/*
* ANYTHING ELSE starting with a '-' is an error.
*/
/*
* ANYTHING ELSE starting with a '-' is an error.
*/
else if (argv[i][0] == '-')
{
show_help = TRUE;
......@@ -391,7 +371,7 @@ main (int argc, char **argv)
g_log_set_handler (NULL, G_LOG_LEVEL_ERROR | G_LOG_FLAG_FATAL,
on_error, NULL);
/* Keep the command line arguments--for use in gimp_init */
gimp_argc = argc - 1;
gimp_argv = argv + 1;
......@@ -402,7 +382,7 @@ main (int argc, char **argv)
/* Main application loop */
if (!app_exit_finish_done ())
gtk_main ();
return 0;
}
......@@ -447,7 +427,7 @@ static int caught_fatal_sig = 0;
#ifndef G_OS_WIN32
static RETSIGTYPE
on_signal (int sig_num)
on_signal (gint sig_num)
{
if (caught_fatal_sig)
kill (getpid (), sig_num);
......@@ -510,8 +490,8 @@ on_signal (int sig_num)
static RETSIGTYPE
on_sig_child (int sig_num)
{
int pid;
int status;
gint pid;
gint status;
while (1)
{
......
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* libgimp-intl.h
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GIMPINTL_H__
#define __GIMPINTL_H__
......
......@@ -697,3 +697,51 @@ gimp_table_attach_aligned (GtkTable *table,
gtk_widget_show (widget);
}
/* add aligned label & widget to a table */
void
gimp_table_attach_aligned2 (GtkTable *table,
gint row,
gchar *label_text,
gfloat xalign,
gfloat yalign,
GtkWidget *widget,
gint widget_left,
gint widget_right,
gboolean left_adjust)
{
if (label_text)
{
GtkWidget *label;
label = gtk_label_new (label_text);
gtk_misc_set_alignment (GTK_MISC (label), xalign, yalign);
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT);
gtk_table_attach (table, GTK_WIDGET (label),
widget_left - 1, widget_left,
row, row + 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (label);
}
if (left_adjust)
{
GtkWidget *alignment;
alignment = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
gtk_table_attach (table, alignment,
widget_left, widget_right,
row, row + 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (alignment);
gtk_container_add (GTK_CONTAINER (alignment), widget);
}
else
{
gtk_table_attach_defaults (table, widget,
widget_left, widget_right,
row, row + 1);
}
gtk_widget_show (widget);
}
......@@ -156,6 +156,17 @@ void gimp_table_attach_aligned (GtkTable *table,
GtkWidget *widget,
gboolean left_adjust);
/* add aligned label & widget to a table */
void gimp_table_attach_aligned2 (GtkTable *table,
gint row,
gchar *label_text,
gfloat xalign,
gfloat yalign,
GtkWidget *widget,
gint widget_left,
gint widget_right,
gboolean left_adjust);
#ifdef __cplusplus
}
#endif
......
......@@ -27,7 +27,7 @@
# undef gettext
# define gettext(String) dgettext ("gimp-libgimp", String)
# ifdef gettext_noop
# define N_(String) dgettext_noop ("gimp-libgimp", String)
# define N_(String) gettext_noop (String)
# else
# define N_(String) (String)
# endif
......
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* libgimp-intl.h
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __STDPLUGINS_INTL_H__
#define __STDPLUGINS_INTL_H__
#include <locale.h>
#include "libgimp/gimpintl.h"
#include "gimpintl.h"
#ifdef HAVE_LC_MESSAGES
#define INIT_I18N() G_STMT_START{ \
setlocale(LC_MESSAGES, ""); \
bindtextdomain("gimp-libgimp", LOCALEDIR); \
bindtextdomain("gimp-std-plugins", LOCALEDIR); \
textdomain("gimp-std-plugins"); \
}G_STMT_END
......
......@@ -697,3 +697,51 @@ gimp_table_attach_aligned (GtkTable *table,
gtk_widget_show (widget);
}
/* add aligned label & widget to a table */
void
gimp_table_attach_aligned2 (GtkTable *table,
gint row,
gchar *label_text,
gfloat xalign,
gfloat yalign,
GtkWidget *widget,
gint widget_left,
gint widget_right,
gboolean left_adjust)
{
if (label_text)
{
GtkWidget *label;
label = gtk_label_new (label_text);
gtk_misc_set_alignment (GTK_MISC (label), xalign, yalign);
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT);
gtk_table_attach (table, GTK_WIDGET (label),
widget_left - 1, widget_left,
row, row + 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (label);
}
if (left_adjust)
{
GtkWidget *alignment;
alignment = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
gtk_table_attach (table, alignment,
widget_left, widget_right,
row, row + 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (alignment);
gtk_container_add (GTK_CONTAINER (alignment), widget);
}
else
{
gtk_table_attach_defaults (table, widget,
widget_left, widget_right,
row, row + 1);
}
gtk_widget_show (widget);
}
......@@ -156,6 +156,17 @@ void gimp_table_attach_aligned (GtkTable *table,
GtkWidget *widget,
gboolean left_adjust);
/* add aligned label & widget to a table */
void gimp_table_attach_aligned2 (GtkTable *table,
gint row,
gchar *label_text,
gfloat xalign,
gfloat yalign,
GtkWidget *widget,
gint widget_left,
gint widget_right,
gboolean left_adjust);
#ifdef __cplusplus
}
#endif
......
This diff is collapsed.
......@@ -33,63 +33,41 @@
#include "libgimp/stdplugins-intl.h"
#define PLUG_IN_NAME "plug_in_align_layers"
#define SHORT_NAME "align_layers"
#define PROGRESS_NAME "align_layers"
#define MAIN_FUNCTION main_function
#define INTERFACE align_layers_interface
#define DIALOG align_layers_dialog
#define VALS align_layers_vals
#define OK_CALLBACK align_layers_ok_callback
#define PREVIEW_UPDATE _preview_update
#define PROGRESS_UPDATE_NUM 100
/* gtkWrapper functions */
#define GTKW_ENTRY_WIDTH 40
#define GTKW_SCALE_WIDTH 100
#define GTKW_PREVIEW_WIDTH 50
#define GTKW_PREVIEW_HEIGHT 256
#define GTKW_BORDER_WIDTH 5
#define GTKW_FLOAT_MIN_ERROR 0.000001
static gint **gtkW_gint_wrapper_new (gint index, gint *pointer);
static void gtkW_toggle_update (GtkWidget *widget, gpointer data);
static void gtkW_table_add_toggle (GtkWidget *table,
gchar *name,
gint x,
gint y,
GtkSignalFunc update,
gint *value);
GtkWidget *gtkW_table_add_button (GtkWidget *table,
gchar *name,
gint x0,
gint x1,
gint y,
GtkSignalFunc callback,
gpointer value);
typedef struct
#define PLUG_IN_NAME "plug_in_align_layers"
#define SHORT_NAME "align_layers"
#define SCALE_WIDTH 150
enum
{
H_NONE,
H_COLLECT,
LEFT2RIGHT,
RIGHT2LEFT,
SNAP2HGRID
};
enum
{
H_BASE_LEFT,
H_BASE_CENTER,
H_BASE_RIGHT
};
enum
{
gchar *name;
gpointer data;
} gtkW_menu_item;
GtkWidget *gtkW_table_add_menu (GtkWidget *parent,
gchar *name,
int x,
int y,
GtkSignalFunc imenu_update,
int *val,
gtkW_menu_item *item,
int item_num);
static void gtkW_menu_update (GtkWidget *widget, gpointer data);
GtkWidget *gtkW_check_button_new (GtkWidget *parent,
gchar *name,
GtkSignalFunc update,
gint *value);
GtkWidget *gtkW_frame_new (GtkWidget *parent, gchar *name);
GtkWidget *gtkW_table_new (GtkWidget *parent, gint col, gint row);
GtkWidget *gtkW_hbox_new (GtkWidget *parent);
GtkWidget *gtkW_vbox_new (GtkWidget *parent);
/* end of GtkW */
V_NONE,
V_COLLECT,
TOP2BOTTOM,
BOTTOM2TOP,
SNAP2VGRID
};
enum
{
V_BASE_TOP,
V_BASE_CENTER,
V_BASE_BOTTOM
};
static void query (void);
static void run (gchar *name,
......@@ -98,12 +76,14 @@ static void run (gchar *name,
gint *nreturn_vals,
GParam **return_vals);
static GStatusType align_layers (gint32 image_id);
static void align_layers_get_align_offsets (gint32 drawable_id,
gint *x,
gint *y);
static gint DIALOG (void);
static void OK_CALLBACK (GtkWidget *widget, gpointer data);
static GStatusType align_layers (gint32 image_id);
static void align_layers_get_align_offsets (gint32 drawable_id,
gint *x,
gint *y);
static gint align_layers_dialog (void);
static void align_layers_ok_callback (GtkWidget *widget,
gpointer data);
GPlugInInfo PLUG_IN_INFO =
{
......@@ -113,55 +93,8 @@ GPlugInInfo PLUG_IN_INFO =
run, /* run_proc */
};
/* dialog variables */
gtkW_menu_item h_style_menu [] =
{
#define H_NONE 0
{ N_("None"), NULL },
#define H_COLLECT 1
{ N_("Collect"), NULL },
#define LEFT2RIGHT 2
{ N_("Fill (left to right)"), NULL },
#define RIGHT2LEFT 3
{ N_("Fill (right to left)"), NULL },
#define SNAP2HGRID 4
{ N_("Snap to grid"), NULL }
};
gtkW_menu_item h_base_menu [] =
{
#define H_BASE_LEFT 0
{ N_("Left edge"), NULL },
#define H_BASE_CENTER 1
{ N_("Center"), NULL },
#define H_BASE_RIGHT 2
{ N_("Right edge"), NULL }
};
gtkW_menu_item v_style_menu [] =
{
#define V_NONE 0
{ N_("None"), NULL },
#define V_COLLECT 1
{ N_("Collect"), NULL },
#define TOP2BOTTOM 2
{ N_("Fill (top to bottom)"), NULL },
#define BOTTOM2TOP 3
{ N_("Fill (bottom to top)"), NULL },
#define SNAP2VGRID 4
{ N_("Snap to grid"), NULL }
};
gtkW_menu_item v_base_menu [] =
{
#define V_BASE_TOP 0
{ N_("Top edge"), NULL },
#define V_BASE_CENTER 1
{ N_("Center"), NULL },
#define V_BASE_BOTTOM 2
{ N_("Bottom edge"), NULL }
};
/* dialog variables */
typedef struct
{
gint h_style;
......@@ -175,7 +108,13 @@ typedef struct
static ValueType VALS =
{
H_NONE, H_BASE_LEFT, V_NONE, V_BASE_TOP, 1, 0, 10
H_NONE,
H_BASE_LEFT,
V_NONE,
V_BASE_TOP,
TRUE,
FALSE,
10
};
typedef struct
......@@ -183,9 +122,11 @@ typedef struct
gint run;
} Interface;
static Interface INTERFACE = { FALSE };
static Interface INTERFACE =
{
FALSE
};
/* gint link_after_alignment = 0;*/
MAIN ()
......@@ -249,7 +190,7 @@ run (gchar *name,
return;
}
gimp_get_data (PLUG_IN_NAME, &VALS);
if (! DIALOG ())
if (! align_layers_dialog ())
return;
break;
case RUN_NONINTERACTIVE:
......@@ -260,12 +201,12 @@ run (gchar *name,
gimp_get_data (PLUG_IN_NAME, &VALS);
break;
}
status = align_layers (image_id);
if (run_mode != RUN_NONINTERACTIVE)
gimp_displays_flush();
if (run_mode == RUN_INTERACTIVE && status == STATUS_SUCCESS )
gimp_displays_flush ();
if (run_mode == RUN_INTERACTIVE && status == STATUS_SUCCESS)
gimp_set_data (PLUG_IN_NAME, &VALS, sizeof (ValueType));
values[0].type = PARAM_STATUS;
......@@ -453,15 +394,16 @@ align_layers_get_align_offsets (gint32 drawable_id,
/* dialog stuff */
static int
DIALOG (void)
align_layers_dialog (void)
{
GtkWidget *dlg;
GtkWidget *frame;
GtkWidget *table;
GtkWidget *optionmenu;
GtkWidget *toggle;
GtkObject *adj;
gchar **argv;
gint argc;
gint index = 0;
argc = 1;
argv = g_new (gchar *, 1);
......@@ -475,7 +417,7 @@ DIALOG (void)
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
_("OK"), OK_CALLBACK,
_("OK"), align_layers_ok_callback,
NULL, NULL, NULL, TRUE, FALSE,
_("Cancel"), gtk_widget_destroy,
NULL, 1, NULL, FALSE, TRUE,
......@@ -485,300 +427,129 @@ DIALOG (void)
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
GTK_SIGNAL_FUNC (gtk_main_quit),
NULL);
frame = gtkW_frame_new (GTK_DIALOG (dlg)->vbox, _("Parameter Settings"));
table = gtkW_table_new (frame, 7, 3);
gtkW_table_add_menu (table, _("Horizontal Style:"), 0, index++,
(GtkSignalFunc) gtkW_menu_update,
&VALS.h_style,
h_style_menu,
sizeof (h_style_menu) / sizeof (h_style_menu[0]));
gtkW_table_add_menu (table, _("Horizontal Base:"), 0, index++,
(GtkSignalFunc) gtkW_menu_update,
&VALS.h_base,
h_base_menu,
sizeof (h_base_menu) / sizeof (h_base_menu[0]));
gtkW_table_add_menu (table, _("Vertical Style:"), 0, index++,
(GtkSignalFunc) gtkW_menu_update,
&VALS.v_style,
v_style_menu,
sizeof (v_style_menu) / sizeof (v_style_menu[0]));
gtkW_table_add_menu (table, _("Vertical Base:"), 0, index++,
(GtkSignalFunc) gtkW_menu_update,
&VALS.v_base,
v_base_menu,
sizeof (v_base_menu) / sizeof (v_base_menu[0]));
gtkW_table_add_toggle (table, _("Ignore the Bottom Layer even if Visible"),
0, index++,
(GtkSignalFunc) gtkW_toggle_update,
&VALS.ignore_bottom);
gtkW_table_add_toggle (table,
_("Use the (Invisible) Bottom Layer as the Base"),