pass a "Gimp" to gui_libs_init(), initialize the GUI before initializing

2001-10-23  Michael Natterer  <mitch@gimp.org>

	* app/app_procs.c: pass a "Gimp" to gui_libs_init(), initialize
	the GUI before initializing the plug-ins.

	* app/gui/menus.[ch]: removed menus_last_opened_add() and connect
	to gimp->documents' "add", "remove" and "reorder" signals to
	auto-update the "last opened" menu entries. Moved all public
	functions to the top of the file. Removed global variable
	"last_opened_raw_filenames".

	* app/gui/gui.[ch]: removed "last opened" fiddling here, moved
	menu init functions which need to be called after plug-in query
	to gui_restore().

	* app/gui/session.[ch]: added "Gimp" parameters to all public
	functions.

	* app/file-save.c
	* app/gui/file-commands.c
	* app/gui/file-open-dialog.c: changed accordingly.
This commit is contained in:
Michael Natterer
2001-10-23 16:23:32 +00:00
committed by Michael Natterer
parent e90d28c480
commit 0da978b8c2
18 changed files with 1658 additions and 1757 deletions

View File

@ -1,3 +1,25 @@
2001-10-23 Michael Natterer <mitch@gimp.org>
* app/app_procs.c: pass a "Gimp" to gui_libs_init(), initialize
the GUI before initializing the plug-ins.
* app/gui/menus.[ch]: removed menus_last_opened_add() and connect
to gimp->documents' "add", "remove" and "reorder" signals to
auto-update the "last opened" menu entries. Moved all public
functions to the top of the file. Removed global variable
"last_opened_raw_filenames".
* app/gui/gui.[ch]: removed "last opened" fiddling here, moved
menu init functions which need to be called after plug-in query
to gui_restore().
* app/gui/session.[ch]: added "Gimp" parameters to all public
functions.
* app/file-save.c
* app/gui/file-commands.c
* app/gui/file-open-dialog.c: changed accordingly.
2001-10-23 Sven Neumann <sven@gimp.org> 2001-10-23 Sven Neumann <sven@gimp.org>
* TODO.xml: added an entry for handling layers with masks with the * TODO.xml: added an entry for handling layers with masks with the

View File

@ -25,6 +25,7 @@
#include "gui-types.h" #include "gui-types.h"
#include "core/gimp.h" #include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h" #include "core/gimpcontext.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimpobject.h" #include "core/gimpobject.h"
@ -37,7 +38,6 @@
#include "file-new-dialog.h" #include "file-new-dialog.h"
#include "file-open-dialog.h" #include "file-open-dialog.h"
#include "file-save-dialog.h" #include "file-save-dialog.h"
#include "menus.h"
#include "app_procs.h" #include "app_procs.h"
#include "file-open.h" #include "file-open.h"
@ -105,24 +105,28 @@ file_last_opened_cmd_callback (GtkWidget *widget,
gpointer data, gpointer data,
guint action) guint action)
{ {
gchar *filename; GimpImagefile *imagefile;
guint num_entries; guint num_entries;
gint status; gint status;
num_entries = g_slist_length (last_opened_raw_filenames); num_entries = gimp_container_num_children (the_gimp->documents);
if (action >= num_entries) if (action >= num_entries)
return; return;
filename = imagefile = (GimpImagefile *)
((GString *) g_slist_nth_data (last_opened_raw_filenames, action))->str; gimp_container_get_child_by_index (the_gimp->documents, action);
status = file_open_with_display (filename); if (imagefile)
{
status = file_open_with_display (GIMP_OBJECT (imagefile)->name);
if (status != GIMP_PDB_SUCCESS && if (status != GIMP_PDB_SUCCESS &&
status != GIMP_PDB_CANCEL) status != GIMP_PDB_CANCEL)
{ {
g_message (_("Error opening file: %s\n"), filename); g_message (_("Error opening file: %s\n"),
GIMP_OBJECT (imagefile)->name);
}
} }
} }

View File

@ -131,7 +131,7 @@ app_init (gint gimp_argc,
if (! no_interface) if (! no_interface)
{ {
gui_libs_init (&gimp_argc, &gimp_argv); gui_libs_init (the_gimp, &gimp_argc, &gimp_argv);
get_standard_colormaps (); get_standard_colormaps ();
@ -161,6 +161,15 @@ app_init (gint gimp_argc,
*/ */
gimp_restore (the_gimp, app_init_update_status, no_data); gimp_restore (the_gimp, app_init_update_status, no_data);
if (! no_interface)
{
#ifdef DISPLAY_FILTERS
color_display_init ();
#endif /* DISPLAY_FILTERS */
gui_init (the_gimp);
}
/* Initialize the plug-in structures /* Initialize the plug-in structures
*/ */
plug_in_init (the_gimp, app_init_update_status); plug_in_init (the_gimp, app_init_update_status);
@ -170,12 +179,6 @@ app_init (gint gimp_argc,
if (! no_splash) if (! no_splash)
splash_destroy (); splash_destroy ();
#ifdef DISPLAY_FILTERS
color_display_init ();
#endif /* DISPLAY_FILTERS */
gui_init (the_gimp);
/* FIXME: This needs to go in preferences */ /* FIXME: This needs to go in preferences */
message_handler = MESSAGE_BOX; message_handler = MESSAGE_BOX;

View File

@ -202,7 +202,6 @@ file_open_with_proc_and_display (const gchar *filename,
absolute = file_open_absolute_filename (filename); absolute = file_open_absolute_filename (filename);
gimp_documents_add (the_gimp, filename); gimp_documents_add (the_gimp, filename);
menus_last_opened_add (absolute);
g_free (absolute); g_free (absolute);
} }
@ -215,7 +214,7 @@ file_open_dialog_create (void)
{ {
GtkFileSelection *file_sel; GtkFileSelection *file_sel;
fileload = gtk_file_selection_new (_("Load Image")); fileload = gtk_file_selection_new (_("Open Image"));
gtk_window_set_position (GTK_WINDOW (fileload), GTK_WIN_POS_MOUSE); gtk_window_set_position (GTK_WINDOW (fileload), GTK_WIN_POS_MOUSE);
gtk_window_set_wmclass (GTK_WINDOW (fileload), "load_image", "Gimp"); gtk_window_set_wmclass (GTK_WINDOW (fileload), "load_image", "Gimp");

View File

@ -69,8 +69,6 @@
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "gui/menus.h"
#include "file-save.h" #include "file-save.h"
#include "file-utils.h" #include "file-utils.h"
#include "plug_in.h" #include "plug_in.h"
@ -177,7 +175,6 @@ file_save (GimpImage *gimage,
gimp_image_clean_all (gimage); gimp_image_clean_all (gimage);
gimp_documents_add (gimage->gimp, filename); gimp_documents_add (gimage->gimp, filename);
menus_last_opened_add (filename);
/* use the same plug-in for this image next time */ /* use the same plug-in for this image next time */
/* DISABLED - gets stuck on first saved format... needs /* DISABLED - gets stuck on first saved format... needs

View File

@ -69,8 +69,6 @@
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "gui/menus.h"
#include "file-save.h" #include "file-save.h"
#include "file-utils.h" #include "file-utils.h"
#include "plug_in.h" #include "plug_in.h"
@ -177,7 +175,6 @@ file_save (GimpImage *gimage,
gimp_image_clean_all (gimage); gimp_image_clean_all (gimage);
gimp_documents_add (gimage->gimp, filename); gimp_documents_add (gimage->gimp, filename);
menus_last_opened_add (filename);
/* use the same plug-in for this image next time */ /* use the same plug-in for this image next time */
/* DISABLED - gets stuck on first saved format... needs /* DISABLED - gets stuck on first saved format... needs

View File

@ -25,6 +25,7 @@
#include "gui-types.h" #include "gui-types.h"
#include "core/gimp.h" #include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h" #include "core/gimpcontext.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimpobject.h" #include "core/gimpobject.h"
@ -37,7 +38,6 @@
#include "file-new-dialog.h" #include "file-new-dialog.h"
#include "file-open-dialog.h" #include "file-open-dialog.h"
#include "file-save-dialog.h" #include "file-save-dialog.h"
#include "menus.h"
#include "app_procs.h" #include "app_procs.h"
#include "file-open.h" #include "file-open.h"
@ -105,24 +105,28 @@ file_last_opened_cmd_callback (GtkWidget *widget,
gpointer data, gpointer data,
guint action) guint action)
{ {
gchar *filename; GimpImagefile *imagefile;
guint num_entries; guint num_entries;
gint status; gint status;
num_entries = g_slist_length (last_opened_raw_filenames); num_entries = gimp_container_num_children (the_gimp->documents);
if (action >= num_entries) if (action >= num_entries)
return; return;
filename = imagefile = (GimpImagefile *)
((GString *) g_slist_nth_data (last_opened_raw_filenames, action))->str; gimp_container_get_child_by_index (the_gimp->documents, action);
status = file_open_with_display (filename); if (imagefile)
{
status = file_open_with_display (GIMP_OBJECT (imagefile)->name);
if (status != GIMP_PDB_SUCCESS && if (status != GIMP_PDB_SUCCESS &&
status != GIMP_PDB_CANCEL) status != GIMP_PDB_CANCEL)
{ {
g_message (_("Error opening file: %s\n"), filename); g_message (_("Error opening file: %s\n"),
GIMP_OBJECT (imagefile)->name);
}
} }
} }

View File

@ -202,7 +202,6 @@ file_open_with_proc_and_display (const gchar *filename,
absolute = file_open_absolute_filename (filename); absolute = file_open_absolute_filename (filename);
gimp_documents_add (the_gimp, filename); gimp_documents_add (the_gimp, filename);
menus_last_opened_add (absolute);
g_free (absolute); g_free (absolute);
} }
@ -215,7 +214,7 @@ file_open_dialog_create (void)
{ {
GtkFileSelection *file_sel; GtkFileSelection *file_sel;
fileload = gtk_file_selection_new (_("Load Image")); fileload = gtk_file_selection_new (_("Open Image"));
gtk_window_set_position (GTK_WINDOW (fileload), GTK_WIN_POS_MOUSE); gtk_window_set_position (GTK_WINDOW (fileload), GTK_WIN_POS_MOUSE);
gtk_window_set_wmclass (GTK_WINDOW (fileload), "load_image", "Gimp"); gtk_window_set_wmclass (GTK_WINDOW (fileload), "load_image", "Gimp");

View File

@ -148,12 +148,15 @@ gui_themes_dir_foreach_func (const gchar *filename,
} }
void void
gui_libs_init (gint *argc, gui_libs_init (Gimp *gimp,
gint *argc,
gchar ***argv) gchar ***argv)
{ {
gchar *theme_dir; gchar *theme_dir;
gchar *gtkrc; gchar *gtkrc;
g_return_if_fail (GIMP_IS_GIMP (gimp));
gimp_stock_init (); gimp_stock_init ();
themes_hash = g_hash_table_new_full (g_str_hash, themes_hash = g_hash_table_new_full (g_str_hash,
@ -210,6 +213,8 @@ gui_libs_init (gint *argc,
void void
gui_init (Gimp *gimp) gui_init (Gimp *gimp)
{ {
g_return_if_fail (GIMP_IS_GIMP (gimp));
gimp->create_display_func = gui_display_new; gimp->create_display_func = gui_display_new;
gimp->gui_set_busy_func = gui_set_busy; gimp->gui_set_busy_func = gui_set_busy;
gimp->gui_unset_busy_func = gui_unset_busy; gimp->gui_unset_busy_func = gui_unset_busy;
@ -269,10 +274,13 @@ gui_init (Gimp *gimp)
gimprc.using_xserver_resolution = TRUE; gimprc.using_xserver_resolution = TRUE;
} }
file_open_dialog_menu_init (); /* tooltips */
file_save_dialog_menu_init (); gimp_help_init ();
menus_reorder_plugins (); if (! gimprc.show_tool_tips)
gimp_help_disable_tooltips ();
menus_init (gimp);
gximage_init (); gximage_init ();
render_setup (gimprc.transparency_type, gimprc.transparency_size); render_setup (gimprc.transparency_type, gimprc.transparency_size);
@ -280,50 +288,34 @@ gui_init (Gimp *gimp)
dialogs_init (gimp); dialogs_init (gimp);
devices_init (); devices_init ();
session_init (); session_init (gimp);
/* tooltips */
gimp_help_init ();
if (! gimprc.show_tool_tips)
gimp_help_disable_tooltips ();
gimp_dialog_factory_dialog_new (global_dialog_factory, "gimp:toolbox");
/* Fill the "last opened" menu items with the first last_opened_size
* elements of gimp->documents
*/
{
GimpImagefile *imagefile;
gint i;
for (i = gimprc.last_opened_size - 1; i >= 0; i--)
{
imagefile = (GimpImagefile *)
gimp_container_get_child_by_index (gimp->documents, i);
if (! imagefile)
continue;
menus_last_opened_add (gimp_object_get_name (GIMP_OBJECT (imagefile)));
}
}
} }
void void
gui_restore (Gimp *gimp) gui_restore (Gimp *gimp)
{ {
g_return_if_fail (GIMP_IS_GIMP (gimp));
file_open_dialog_menu_init ();
file_save_dialog_menu_init ();
menus_restore (gimp);
gimp_dialog_factory_dialog_new (global_dialog_factory, "gimp:toolbox");
color_select_init (); color_select_init ();
devices_restore (); devices_restore ();
if (restore_session) if (restore_session)
session_restore (); session_restore (gimp);
} }
void void
gui_post_init (Gimp *gimp) gui_post_init (Gimp *gimp)
{ {
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (gimprc.show_tips) if (gimprc.show_tips)
{ {
gimp_dialog_factory_dialog_new (global_dialog_factory, "gimp:tips-dialog"); gimp_dialog_factory_dialog_new (global_dialog_factory, "gimp:tips-dialog");
@ -333,7 +325,9 @@ gui_post_init (Gimp *gimp)
void void
gui_shutdown (Gimp *gimp) gui_shutdown (Gimp *gimp)
{ {
session_save (); g_return_if_fail (GIMP_IS_GIMP (gimp));
session_save (gimp);
device_status_free (); device_status_free ();
brush_dialog_free (); brush_dialog_free ();
@ -347,7 +341,9 @@ gui_shutdown (Gimp *gimp)
void void
gui_exit (Gimp *gimp) gui_exit (Gimp *gimp)
{ {
menus_quit (); g_return_if_fail (GIMP_IS_GIMP (gimp));
menus_exit (gimp);
gximage_free (); gximage_free ();
render_free (); render_free ();

View File

@ -20,7 +20,8 @@
#define __GUI_H__ #define __GUI_H__
void gui_libs_init (gint *argc, void gui_libs_init (Gimp *gimp,
gint *argc,
gchar ***argv); gchar ***argv);
void gui_init (Gimp *gimp); void gui_init (Gimp *gimp);

File diff suppressed because it is too large Load Diff

View File

@ -33,8 +33,9 @@ struct _GimpItemFactoryEntry
}; };
extern GSList *last_opened_raw_filenames; void menus_init (Gimp *gimp);
void menus_exit (Gimp *gimp);
void menus_restore (Gimp *gimp);
GtkItemFactory * menus_get_toolbox_factory (void); GtkItemFactory * menus_get_toolbox_factory (void);
GtkItemFactory * menus_get_image_factory (void); GtkItemFactory * menus_get_image_factory (void);
@ -54,17 +55,11 @@ void menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
gchar *domain_name, gchar *domain_name,
gpointer callback_data); gpointer callback_data);
void menus_reorder_plugins (void);
void menus_quit (void);
void menus_set_sensitive (gchar *path, void menus_set_sensitive (gchar *path,
gboolean sensitive); gboolean sensitive);
void menus_set_state (gchar *path, void menus_set_state (gchar *path,
gboolean state); gboolean state);
void menus_destroy (gchar *path); void menus_destroy (gchar *path);
void menus_last_opened_add (const gchar *filename);
#endif /* __MENUS_H__ */ #endif /* __MENUS_H__ */

View File

@ -47,6 +47,8 @@
#include "gui-types.h" #include "gui-types.h"
#include "core/gimp.h"
#include "widgets/gimpdialogfactory.h" #include "widgets/gimpdialogfactory.h"
#include "color-notebook.h" #include "color-notebook.h"
@ -59,10 +61,12 @@
/* public functions */ /* public functions */
void void
session_init (void) session_init (Gimp *gimp)
{ {
gchar *filename; gchar *filename;
g_return_if_fail (GIMP_IS_GIMP (gimp));
filename = gimp_personal_rc_file ("sessionrc"); filename = gimp_personal_rc_file ("sessionrc");
if (! gimprc_parse_file (filename)) if (! gimprc_parse_file (filename))
@ -76,17 +80,21 @@ session_init (void)
} }
void void
session_restore (void) session_restore (Gimp *gimp)
{ {
g_return_if_fail (GIMP_IS_GIMP (gimp));
gimp_dialog_factories_session_restore (); gimp_dialog_factories_session_restore ();
} }
void void
session_save (void) session_save (Gimp *gimp)
{ {
gchar *filename; gchar *filename;
FILE *fp; FILE *fp;
g_return_if_fail (GIMP_IS_GIMP (gimp));
filename = gimp_personal_rc_file ("sessionrc"); filename = gimp_personal_rc_file ("sessionrc");
fp = fopen (filename, "wt"); fp = fopen (filename, "wt");

View File

@ -20,9 +20,9 @@
#define __SESSION_H__ #define __SESSION_H__
void session_init (void); void session_init (Gimp *gimp);
void session_restore (void); void session_restore (Gimp *gimp);
void session_save (void); void session_save (Gimp *gimp);
#endif /* __SESSION_H__ */ #endif /* __SESSION_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -33,8 +33,9 @@ struct _GimpItemFactoryEntry
}; };
extern GSList *last_opened_raw_filenames; void menus_init (Gimp *gimp);
void menus_exit (Gimp *gimp);
void menus_restore (Gimp *gimp);
GtkItemFactory * menus_get_toolbox_factory (void); GtkItemFactory * menus_get_toolbox_factory (void);
GtkItemFactory * menus_get_image_factory (void); GtkItemFactory * menus_get_image_factory (void);
@ -54,17 +55,11 @@ void menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
gchar *domain_name, gchar *domain_name,
gpointer callback_data); gpointer callback_data);
void menus_reorder_plugins (void);
void menus_quit (void);
void menus_set_sensitive (gchar *path, void menus_set_sensitive (gchar *path,
gboolean sensitive); gboolean sensitive);
void menus_set_state (gchar *path, void menus_set_state (gchar *path,
gboolean state); gboolean state);
void menus_destroy (gchar *path); void menus_destroy (gchar *path);
void menus_last_opened_add (const gchar *filename);
#endif /* __MENUS_H__ */ #endif /* __MENUS_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -33,8 +33,9 @@ struct _GimpItemFactoryEntry
}; };
extern GSList *last_opened_raw_filenames; void menus_init (Gimp *gimp);
void menus_exit (Gimp *gimp);
void menus_restore (Gimp *gimp);
GtkItemFactory * menus_get_toolbox_factory (void); GtkItemFactory * menus_get_toolbox_factory (void);
GtkItemFactory * menus_get_image_factory (void); GtkItemFactory * menus_get_image_factory (void);
@ -54,17 +55,11 @@ void menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
gchar *domain_name, gchar *domain_name,
gpointer callback_data); gpointer callback_data);
void menus_reorder_plugins (void);
void menus_quit (void);
void menus_set_sensitive (gchar *path, void menus_set_sensitive (gchar *path,
gboolean sensitive); gboolean sensitive);
void menus_set_state (gchar *path, void menus_set_state (gchar *path,
gboolean state); gboolean state);
void menus_destroy (gchar *path); void menus_destroy (gchar *path);
void menus_last_opened_add (const gchar *filename);
#endif /* __MENUS_H__ */ #endif /* __MENUS_H__ */