gimp/app/dialogs/info-dialog.c

468 lines
12 KiB
C
Raw Normal View History

1997-11-25 06:05:25 +08:00
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1997-11-25 06:05:25 +08:00
*/
Makefile.am configure.in added the new library below. 2001-01-24 Michael Natterer <mitch@gimp.org> * Makefile.am * configure.in * gimptool.in: added the new library below. * libgimpwidgets/Makefile.am * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.[ch] * libgimpwidgets/gimpcolorbutton.[ch] * libgimpwidgets/gimpdialog.[ch] * libgimpwidgets/gimpfileselection.[ch] * libgimpwidgets/gimphelpui.[ch] * libgimpwidgets/gimppatheditor.[ch] * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpquerybox.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch] * libgimpwidgets/gimpwidgets.[ch] * libgimpwidgets/gimpwidgets.def * libgimpwidgets/gimpwidgetstypes.h: new shared library. Currently there are some ugly dependencies into libgimp. These will be removed and go to a "libgimpglue" library which will be a library for functions which share a common interface between plug-ins and the app but have different implementations. Include "libgimp/gimpunit.h" from "libgimpwidgets/gimpwidgetstypes.h" to simulate this upcoming separation. * libgimp/Makefile.am * libgimp/gimpchainbutton.[ch] * libgimp/gimpcolorarea.[ch] * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimpfileselection.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimppixmap.[ch] * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: removed from here. * libgimp/gimpui.h * libgimp/gimpuitypes.h * libgimp/makefile.mingw.in * libgimp/makefile.msc: changed accordingly. * app/[all ui files] * app/pdb/palette_cmds.c * app/pdb/tools_cmds.c * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: #include "libgimpwidgets/gimpwidgets.h" and removed useless includes. * app/apptypes.h: #include "libgimpwidgets/gimpwidgetstypes.h" * app/Makefile.am * plug-ins/[all makefiles which link against libgimpui]: link against libgimpwidgets.la * po-libgimp/POTFILES.in: changed file locations.
2001-01-25 06:36:18 +08:00
#include "config.h"
1997-11-25 06:05:25 +08:00
#include <string.h>
#include <gtk/gtk.h>
Makefile.am configure.in added the new library below. 2001-01-24 Michael Natterer <mitch@gimp.org> * Makefile.am * configure.in * gimptool.in: added the new library below. * libgimpwidgets/Makefile.am * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.[ch] * libgimpwidgets/gimpcolorbutton.[ch] * libgimpwidgets/gimpdialog.[ch] * libgimpwidgets/gimpfileselection.[ch] * libgimpwidgets/gimphelpui.[ch] * libgimpwidgets/gimppatheditor.[ch] * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpquerybox.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch] * libgimpwidgets/gimpwidgets.[ch] * libgimpwidgets/gimpwidgets.def * libgimpwidgets/gimpwidgetstypes.h: new shared library. Currently there are some ugly dependencies into libgimp. These will be removed and go to a "libgimpglue" library which will be a library for functions which share a common interface between plug-ins and the app but have different implementations. Include "libgimp/gimpunit.h" from "libgimpwidgets/gimpwidgetstypes.h" to simulate this upcoming separation. * libgimp/Makefile.am * libgimp/gimpchainbutton.[ch] * libgimp/gimpcolorarea.[ch] * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimpfileselection.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimppixmap.[ch] * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: removed from here. * libgimp/gimpui.h * libgimp/gimpuitypes.h * libgimp/makefile.mingw.in * libgimp/makefile.msc: changed accordingly. * app/[all ui files] * app/pdb/palette_cmds.c * app/pdb/tools_cmds.c * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: #include "libgimpwidgets/gimpwidgets.h" and removed useless includes. * app/apptypes.h: #include "libgimpwidgets/gimpwidgetstypes.h" * app/Makefile.am * plug-ins/[all makefiles which link against libgimpui]: link against libgimpwidgets.la * po-libgimp/POTFILES.in: changed file locations.
2001-01-25 06:36:18 +08:00
#include "libgimpwidgets/gimpwidgets.h"
#include "apptypes.h"
#include "dialog_handler.h"
1997-11-25 06:05:25 +08:00
#include "gimprc.h"
#include "info_dialog.h"
#include "session.h"
1997-11-25 06:05:25 +08:00
#include "libgimp/gimpintl.h"
1997-11-25 06:05:25 +08:00
/* static functions */
Makefile.am configure.in added the new library below. 2001-01-24 Michael Natterer <mitch@gimp.org> * Makefile.am * configure.in * gimptool.in: added the new library below. * libgimpwidgets/Makefile.am * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.[ch] * libgimpwidgets/gimpcolorbutton.[ch] * libgimpwidgets/gimpdialog.[ch] * libgimpwidgets/gimpfileselection.[ch] * libgimpwidgets/gimphelpui.[ch] * libgimpwidgets/gimppatheditor.[ch] * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpquerybox.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch] * libgimpwidgets/gimpwidgets.[ch] * libgimpwidgets/gimpwidgets.def * libgimpwidgets/gimpwidgetstypes.h: new shared library. Currently there are some ugly dependencies into libgimp. These will be removed and go to a "libgimpglue" library which will be a library for functions which share a common interface between plug-ins and the app but have different implementations. Include "libgimp/gimpunit.h" from "libgimpwidgets/gimpwidgetstypes.h" to simulate this upcoming separation. * libgimp/Makefile.am * libgimp/gimpchainbutton.[ch] * libgimp/gimpcolorarea.[ch] * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimpfileselection.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimppixmap.[ch] * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: removed from here. * libgimp/gimpui.h * libgimp/gimpuitypes.h * libgimp/makefile.mingw.in * libgimp/makefile.msc: changed accordingly. * app/[all ui files] * app/pdb/palette_cmds.c * app/pdb/tools_cmds.c * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: #include "libgimpwidgets/gimpwidgets.h" and removed useless includes. * app/apptypes.h: #include "libgimpwidgets/gimpwidgetstypes.h" * app/Makefile.am * plug-ins/[all makefiles which link against libgimpui]: link against libgimpwidgets.la * po-libgimp/POTFILES.in: changed file locations.
2001-01-25 06:36:18 +08:00
static void info_field_new (InfoDialog *idialog,
InfoFieldType field_type,
gchar *title,
GtkWidget *widget,
GtkObject *object,
gpointer value_ptr,
GtkSignalFunc callback,
gpointer client_data);
static void update_field (InfoField *info_field);
static gint info_dialog_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer data);
1997-11-25 06:05:25 +08:00
static void
info_field_new (InfoDialog *idialog,
InfoFieldType field_type,
gchar *title,
GtkWidget *widget,
GtkObject *obj,
void *value_ptr,
GtkSignalFunc callback,
gpointer client_data)
1997-11-25 06:05:25 +08:00
{
GtkWidget *label;
InfoField *field;
gint row;
1997-11-25 06:05:25 +08:00
field = g_new (InfoField, 1);
1997-11-25 06:05:25 +08:00
row = idialog->nfields + 1;
gtk_table_resize (GTK_TABLE (idialog->info_table), 2, row);
label = gtk_label_new (title);
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (idialog->info_table), label,
0, 1, row - 1, row,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (label);
1997-11-25 06:05:25 +08:00
gtk_table_attach_defaults (GTK_TABLE (idialog->info_table), widget,
1, 2, row - 1, row);
gtk_widget_show (widget);
1997-11-25 06:05:25 +08:00
gtk_table_set_col_spacing (GTK_TABLE (idialog->info_table), 0, 6);
gtk_table_set_row_spacings (GTK_TABLE (idialog->info_table), 2);
1997-11-25 06:05:25 +08:00
field->field_type = field_type;
if (obj == NULL)
field->obj = GTK_OBJECT (widget);
else
field->obj = obj;
field->value_ptr = value_ptr;
field->callback = callback;
field->client_data = client_data;
idialog->field_list =
g_slist_prepend (idialog->field_list, (void *) field);
idialog->nfields++;
1997-11-25 06:05:25 +08:00
}
static void
update_field (InfoField *field)
{
gchar *old_text;
gint num;
gint i;
1997-11-25 06:05:25 +08:00
if (field->value_ptr == NULL)
return;
1997-11-25 06:05:25 +08:00
if (field->field_type != INFO_LABEL)
gtk_signal_handler_block_by_data (GTK_OBJECT (field->obj),
field->client_data);
switch (field->field_type)
1997-11-25 06:05:25 +08:00
{
case INFO_LABEL:
gtk_label_get (GTK_LABEL (field->obj), &old_text);
if (strcmp (old_text, (gchar*) field->value_ptr))
gtk_label_set_text (GTK_LABEL (field->obj), (gchar*) field->value_ptr);
break;
case INFO_ENTRY:
old_text = gtk_entry_get_text (GTK_ENTRY (field->obj));
if (strcmp (old_text, (gchar*) field->value_ptr))
gtk_entry_set_text (GTK_ENTRY (field->obj), (gchar*) field->value_ptr);
break;
case INFO_SCALE:
case INFO_SPINBUTTON:
gtk_adjustment_set_value (GTK_ADJUSTMENT (field->obj),
*((gdouble*) field->value_ptr));
break;
case INFO_SIZEENTRY:
num = GIMP_SIZE_ENTRY (field->obj)->number_of_fields;
for (i = 0; i < num; i++)
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (field->obj), i,
((gdouble*) field->value_ptr)[i]);
break;
default:
g_warning ("Unknown info_dialog field type.");
break;
1997-11-25 06:05:25 +08:00
}
if (field->field_type != INFO_LABEL)
gtk_signal_handler_unblock_by_data (GTK_OBJECT (field->obj),
field->client_data);
1997-11-25 06:05:25 +08:00
}
static gint
info_dialog_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
info_dialog_popdown ((InfoDialog *) data);
return TRUE;
}
static InfoDialog *
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
info_dialog_new_extended (gchar *title,
GimpHelpFunc help_func,
gpointer help_data,
gboolean in_notebook)
1997-11-25 06:05:25 +08:00
{
InfoDialog *idialog;
GtkWidget *shell;
GtkWidget *vbox;
GtkWidget *info_table;
GtkWidget *info_notebook;
1997-11-25 06:05:25 +08:00
idialog = g_new (InfoDialog, 1);
1997-11-25 06:05:25 +08:00
idialog->field_list = NULL;
idialog->nfields = 0;
1997-11-25 06:05:25 +08:00
shell = gtk_dialog_new ();
gtk_window_set_wmclass (GTK_WINDOW (shell), "info_dialog", "Gimp");
gtk_window_set_title (GTK_WINDOW (shell), title);
session_set_window_geometry (shell, &info_dialog_session_info, FALSE );
1997-11-25 06:05:25 +08:00
dialog_register (shell);
1997-11-25 06:05:25 +08:00
gtk_signal_connect (GTK_OBJECT (shell), "delete_event",
GTK_SIGNAL_FUNC (info_dialog_delete_callback),
idialog);
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (shell)->vbox), vbox);
1997-11-25 06:05:25 +08:00
info_table = gtk_table_new (2, 0, FALSE);
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
if (in_notebook)
{
info_notebook = gtk_notebook_new ();
2000-02-12 22:38:15 +08:00
gtk_container_set_border_width (GTK_CONTAINER (info_table), 4);
gtk_notebook_append_page (GTK_NOTEBOOK (info_notebook),
info_table,
gtk_label_new (_("General")));
gtk_box_pack_start (GTK_BOX (vbox), info_notebook, FALSE, FALSE, 0);
}
else
{
info_notebook = NULL;
gtk_box_pack_start (GTK_BOX (vbox), info_table, FALSE, FALSE, 0);
}
1997-11-25 06:05:25 +08:00
idialog->shell = shell;
idialog->vbox = vbox;
idialog->info_table = info_table;
idialog->info_notebook = info_notebook;
if (in_notebook)
gtk_widget_show (idialog->info_notebook);
1997-11-25 06:05:25 +08:00
gtk_widget_show (idialog->info_table);
1997-11-25 06:05:25 +08:00
gtk_widget_show (idialog->vbox);
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
/* Connect the "F1" help key */
gimp_help_connect_help_accel (idialog->shell, help_func, help_data);
1997-11-25 06:05:25 +08:00
return idialog;
}
/* public functions */
InfoDialog *
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
info_dialog_notebook_new (gchar *title,
GimpHelpFunc help_func,
gpointer help_data)
{
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
return info_dialog_new_extended (title, help_func, help_data, TRUE);
}
InfoDialog *
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
info_dialog_new (gchar *title,
GimpHelpFunc help_func,
gpointer help_data)
{
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
return info_dialog_new_extended (title, help_func, help_data, FALSE);
}
1997-11-25 06:05:25 +08:00
void
info_dialog_free (InfoDialog *idialog)
{
GSList *list;
1997-11-25 06:05:25 +08:00
g_return_if_fail (idialog != NULL);
1997-11-25 06:05:25 +08:00
/* Free each item in the field list */
for (list = idialog->field_list; list; list = g_slist_next (list))
g_free (list->data);
1997-11-25 06:05:25 +08:00
/* Free the actual field linked list */
g_slist_free (idialog->field_list);
1997-11-25 06:05:25 +08:00
dialog_unregister (idialog->shell);
session_get_window_info (idialog->shell, &info_dialog_session_info);
1997-11-25 06:05:25 +08:00
/* Destroy the associated widgets */
gtk_widget_destroy (idialog->shell);
/* Free the info dialog memory */
g_free (idialog);
}
void
info_dialog_popup (InfoDialog *idialog)
{
if (! idialog)
return;
if (! GTK_WIDGET_VISIBLE (idialog->shell))
gtk_widget_show (idialog->shell);
}
void
info_dialog_popdown (InfoDialog *idialog)
{
if (! idialog)
return;
if (GTK_WIDGET_VISIBLE (idialog->shell))
gtk_widget_hide (idialog->shell);
}
void
info_dialog_update (InfoDialog *idialog)
{
GSList *list;
if (! idialog)
return;
for (list = idialog->field_list; list; list = g_slist_next (list))
update_field ((InfoField *) list->data);
}
GtkWidget *
info_dialog_add_label (InfoDialog *idialog,
char *title,
char *text_ptr)
{
GtkWidget *label;
g_return_val_if_fail (idialog != NULL, NULL);
label = gtk_label_new (text_ptr);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
info_field_new (idialog, INFO_LABEL, title, label, NULL, (void*) text_ptr,
NULL, NULL);
return label;
}
GtkWidget *
info_dialog_add_entry (InfoDialog *idialog,
char *title,
char *text_ptr,
GtkSignalFunc callback,
gpointer data)
1997-11-25 06:05:25 +08:00
{
GtkWidget *entry;
1997-11-25 06:05:25 +08:00
g_return_val_if_fail (idialog != NULL, NULL);
1997-11-25 06:05:25 +08:00
entry = gtk_entry_new ();
gtk_widget_set_usize (entry, 50, 0);
gtk_entry_set_text (GTK_ENTRY (entry), text_ptr ? text_ptr : "");
if (callback)
gtk_signal_connect (GTK_OBJECT (entry), "changed",
GTK_SIGNAL_FUNC (callback), data);
info_field_new (idialog, INFO_ENTRY, title, entry, NULL, (void*) text_ptr,
callback, data);
return entry;
}
GtkWidget *
info_dialog_add_scale (InfoDialog *idialog,
gchar *title,
gdouble *value_ptr,
gfloat lower,
gfloat upper,
gfloat step_increment,
gfloat page_increment,
gfloat page_size,
gint digits,
GtkSignalFunc callback,
gpointer data)
{
GtkObject *adjustment;
GtkWidget *scale;
g_return_val_if_fail (idialog != NULL, NULL);
adjustment = gtk_adjustment_new (value_ptr ? *value_ptr : 0, lower, upper,
step_increment, page_increment, page_size);
scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
if (digits >= 0)
gtk_scale_set_digits (GTK_SCALE (scale), MAX (digits, 6));
else
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
if (callback)
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (callback), data);
info_field_new (idialog, INFO_SCALE, title, scale, adjustment,
(void*) value_ptr, callback, data);
return scale;
}
GtkWidget *
info_dialog_add_spinbutton (InfoDialog *idialog,
gchar *title,
gdouble *value_ptr,
gfloat lower,
gfloat upper,
gfloat step_increment,
gfloat page_increment,
gfloat page_size,
gfloat climb_rate,
gint digits,
GtkSignalFunc callback,
gpointer data)
{
GtkWidget *alignment;
GtkObject *adjustment;
GtkWidget *spinbutton;
g_return_val_if_fail (idialog != NULL, NULL);
alignment = gtk_alignment_new (0.0, 0.5, 0.0, 1.0);
adjustment = gtk_adjustment_new (value_ptr ? *value_ptr : 0, lower, upper,
step_increment, page_increment, page_size);
spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment),
climb_rate, MAX (MIN (digits, 6), 0));
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton),
GTK_SHADOW_NONE);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
gtk_widget_set_usize (spinbutton, 75, 0);
if (callback)
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed",
GTK_SIGNAL_FUNC (callback), data);
gtk_container_add (GTK_CONTAINER (alignment), spinbutton);
gtk_widget_show (spinbutton);
info_field_new (idialog, INFO_SPINBUTTON, title, alignment, adjustment,
(void*) value_ptr, callback, data);
return spinbutton;
}
GtkWidget *
info_dialog_add_sizeentry (InfoDialog *idialog,
gchar *title,
gdouble *value_ptr,
gint nfields,
GimpUnit unit,
gchar *unit_format,
gboolean menu_show_pixels,
gboolean menu_show_percent,
gboolean show_refval,
GimpSizeEntryUpdatePolicy update_policy,
GtkSignalFunc callback,
gpointer data)
{
GtkWidget *alignment;
GtkWidget *sizeentry;
gint i;
g_return_val_if_fail (idialog != NULL, NULL);
alignment = gtk_alignment_new (0.0, 0.5, 0.0, 1.0);
sizeentry = gimp_size_entry_new (nfields, unit, unit_format,
menu_show_pixels, menu_show_percent,
show_refval, 75,
update_policy);
if (value_ptr)
for (i = 0; i < nfields; i++)
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), i, value_ptr[i]);
if (callback)
gtk_signal_connect (GTK_OBJECT (sizeentry), "value_changed",
GTK_SIGNAL_FUNC (callback), data);
gtk_container_add (GTK_CONTAINER (alignment), sizeentry);
gtk_widget_show (sizeentry);
info_field_new (idialog, INFO_SIZEENTRY, title, alignment,
GTK_OBJECT (sizeentry),
(void*) value_ptr, callback, data);
return sizeentry;
1997-11-25 06:05:25 +08:00
}