Commit 0da978b8 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

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.
parent e90d28c4
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>
* TODO.xml: added an entry for handling layers with masks with the
......
......@@ -25,6 +25,7 @@
#include "gui-types.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpobject.h"
......@@ -37,7 +38,6 @@
#include "file-new-dialog.h"
#include "file-open-dialog.h"
#include "file-save-dialog.h"
#include "menus.h"
#include "app_procs.h"
#include "file-open.h"
......@@ -105,24 +105,28 @@ file_last_opened_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
gchar *filename;
guint num_entries;
gint status;
GimpImagefile *imagefile;
guint num_entries;
gint status;
num_entries = g_slist_length (last_opened_raw_filenames);
num_entries = gimp_container_num_children (the_gimp->documents);
if (action >= num_entries)
return;
filename =
((GString *) g_slist_nth_data (last_opened_raw_filenames, action))->str;
imagefile = (GimpImagefile *)
gimp_container_get_child_by_index (the_gimp->documents, action);
status = file_open_with_display (filename);
if (status != GIMP_PDB_SUCCESS &&
status != GIMP_PDB_CANCEL)
if (imagefile)
{
g_message (_("Error opening file: %s\n"), filename);
status = file_open_with_display (GIMP_OBJECT (imagefile)->name);
if (status != GIMP_PDB_SUCCESS &&
status != GIMP_PDB_CANCEL)
{
g_message (_("Error opening file: %s\n"),
GIMP_OBJECT (imagefile)->name);
}
}
}
......
......@@ -131,7 +131,7 @@ app_init (gint gimp_argc,
if (! no_interface)
{
gui_libs_init (&gimp_argc, &gimp_argv);
gui_libs_init (the_gimp, &gimp_argc, &gimp_argv);
get_standard_colormaps ();
......@@ -161,6 +161,15 @@ app_init (gint gimp_argc,
*/
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
*/
plug_in_init (the_gimp, app_init_update_status);
......@@ -170,12 +179,6 @@ app_init (gint gimp_argc,
if (! no_splash)
splash_destroy ();
#ifdef DISPLAY_FILTERS
color_display_init ();
#endif /* DISPLAY_FILTERS */
gui_init (the_gimp);
/* FIXME: This needs to go in preferences */
message_handler = MESSAGE_BOX;
......
......@@ -202,7 +202,6 @@ file_open_with_proc_and_display (const gchar *filename,
absolute = file_open_absolute_filename (filename);
gimp_documents_add (the_gimp, filename);
menus_last_opened_add (absolute);
g_free (absolute);
}
......@@ -215,7 +214,7 @@ file_open_dialog_create (void)
{
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_wmclass (GTK_WINDOW (fileload), "load_image", "Gimp");
......
......@@ -69,8 +69,6 @@
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "gui/menus.h"
#include "file-save.h"
#include "file-utils.h"
#include "plug_in.h"
......@@ -177,7 +175,6 @@ file_save (GimpImage *gimage,
gimp_image_clean_all (gimage);
gimp_documents_add (gimage->gimp, filename);
menus_last_opened_add (filename);
/* use the same plug-in for this image next time */
/* DISABLED - gets stuck on first saved format... needs
......
......@@ -69,8 +69,6 @@
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "gui/menus.h"
#include "file-save.h"
#include "file-utils.h"
#include "plug_in.h"
......@@ -177,7 +175,6 @@ file_save (GimpImage *gimage,
gimp_image_clean_all (gimage);
gimp_documents_add (gimage->gimp, filename);
menus_last_opened_add (filename);
/* use the same plug-in for this image next time */
/* DISABLED - gets stuck on first saved format... needs
......
......@@ -25,6 +25,7 @@
#include "gui-types.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpobject.h"
......@@ -37,7 +38,6 @@
#include "file-new-dialog.h"
#include "file-open-dialog.h"
#include "file-save-dialog.h"
#include "menus.h"
#include "app_procs.h"
#include "file-open.h"
......@@ -105,24 +105,28 @@ file_last_opened_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
gchar *filename;
guint num_entries;
gint status;
GimpImagefile *imagefile;
guint num_entries;
gint status;
num_entries = g_slist_length (last_opened_raw_filenames);
num_entries = gimp_container_num_children (the_gimp->documents);
if (action >= num_entries)
return;
filename =
((GString *) g_slist_nth_data (last_opened_raw_filenames, action))->str;
imagefile = (GimpImagefile *)
gimp_container_get_child_by_index (the_gimp->documents, action);
status = file_open_with_display (filename);
if (status != GIMP_PDB_SUCCESS &&
status != GIMP_PDB_CANCEL)
if (imagefile)
{
g_message (_("Error opening file: %s\n"), filename);
status = file_open_with_display (GIMP_OBJECT (imagefile)->name);
if (status != GIMP_PDB_SUCCESS &&
status != GIMP_PDB_CANCEL)
{
g_message (_("Error opening file: %s\n"),
GIMP_OBJECT (imagefile)->name);
}
}
}
......
......@@ -202,7 +202,6 @@ file_open_with_proc_and_display (const gchar *filename,
absolute = file_open_absolute_filename (filename);
gimp_documents_add (the_gimp, filename);
menus_last_opened_add (absolute);
g_free (absolute);
}
......@@ -215,7 +214,7 @@ file_open_dialog_create (void)
{
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_wmclass (GTK_WINDOW (fileload), "load_image", "Gimp");
......
......@@ -148,12 +148,15 @@ gui_themes_dir_foreach_func (const gchar *filename,
}
void
gui_libs_init (gint *argc,
gui_libs_init (Gimp *gimp,
gint *argc,
gchar ***argv)
{
gchar *theme_dir;
gchar *gtkrc;
g_return_if_fail (GIMP_IS_GIMP (gimp));
gimp_stock_init ();
themes_hash = g_hash_table_new_full (g_str_hash,
......@@ -210,6 +213,8 @@ gui_libs_init (gint *argc,
void
gui_init (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
gimp->create_display_func = gui_display_new;
gimp->gui_set_busy_func = gui_set_busy;
gimp->gui_unset_busy_func = gui_unset_busy;
......@@ -269,61 +274,48 @@ gui_init (Gimp *gimp)
gimprc.using_xserver_resolution = TRUE;
}
file_open_dialog_menu_init ();
file_save_dialog_menu_init ();
menus_reorder_plugins ();
gximage_init ();
render_setup (gimprc.transparency_type, gimprc.transparency_size);
dialogs_init (gimp);
devices_init ();
session_init ();
/* 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;
menus_init (gimp);
for (i = gimprc.last_opened_size - 1; i >= 0; i--)
{
imagefile = (GimpImagefile *)
gimp_container_get_child_by_index (gimp->documents, i);
gximage_init ();
render_setup (gimprc.transparency_type, gimprc.transparency_size);
if (! imagefile)
continue;
dialogs_init (gimp);
menus_last_opened_add (gimp_object_get_name (GIMP_OBJECT (imagefile)));
}
}
devices_init ();
session_init (gimp);
}
void
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 ();
devices_restore ();
if (restore_session)
session_restore ();
session_restore (gimp);
}
void
gui_post_init (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (gimprc.show_tips)
{
gimp_dialog_factory_dialog_new (global_dialog_factory, "gimp:tips-dialog");
......@@ -333,7 +325,9 @@ gui_post_init (Gimp *gimp)
void
gui_shutdown (Gimp *gimp)
{
session_save ();
g_return_if_fail (GIMP_IS_GIMP (gimp));
session_save (gimp);
device_status_free ();
brush_dialog_free ();
......@@ -347,7 +341,9 @@ gui_shutdown (Gimp *gimp)
void
gui_exit (Gimp *gimp)
{
menus_quit ();
g_return_if_fail (GIMP_IS_GIMP (gimp));
menus_exit (gimp);
gximage_free ();
render_free ();
......
......@@ -20,7 +20,8 @@
#define __GUI_H__
void gui_libs_init (gint *argc,
void gui_libs_init (Gimp *gimp,
gint *argc,
gchar ***argv);
void gui_init (Gimp *gimp);
......
This diff is collapsed.
......@@ -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_image_factory (void);
......@@ -54,17 +55,11 @@ void menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
gchar *domain_name,
gpointer callback_data);
void menus_reorder_plugins (void);
void menus_quit (void);
void menus_set_sensitive (gchar *path,
gboolean sensitive);
void menus_set_state (gchar *path,
gboolean state);
void menus_destroy (gchar *path);
void menus_last_opened_add (const gchar *filename);
#endif /* __MENUS_H__ */
......@@ -47,6 +47,8 @@
#include "gui-types.h"
#include "core/gimp.h"
#include "widgets/gimpdialogfactory.h"
#include "color-notebook.h"
......@@ -59,10 +61,12 @@
/* public functions */
void
session_init (void)
session_init (Gimp *gimp)
{
gchar *filename;
g_return_if_fail (GIMP_IS_GIMP (gimp));
filename = gimp_personal_rc_file ("sessionrc");
if (! gimprc_parse_file (filename))
......@@ -76,17 +80,21 @@ session_init (void)
}
void
session_restore (void)
session_restore (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
gimp_dialog_factories_session_restore ();
}
void
session_save (void)
session_save (Gimp *gimp)
{
gchar *filename;
FILE *fp;
g_return_if_fail (GIMP_IS_GIMP (gimp));
filename = gimp_personal_rc_file ("sessionrc");
fp = fopen (filename, "wt");
......
......@@ -20,9 +20,9 @@
#define __SESSION_H__
void session_init (void);
void session_restore (void);
void session_save (void);
void session_init (Gimp *gimp);
void session_restore (Gimp *gimp);
void session_save (Gimp *gimp);
#endif /* __SESSION_H__ */
This diff is collapsed.
......@@ -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_image_factory (void);
......@@ -54,17 +55,11 @@ void menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
gchar *domain_name,
gpointer callback_data);
void menus_reorder_plugins (void);
void menus_quit (void);
void menus_set_sensitive (gchar *path,
gboolean sensitive);
void menus_set_state (gchar *path,
gboolean state);
void menus_destroy (gchar *path);
void menus_last_opened_add (const gchar *filename);
#endif /* __MENUS_H__ */
This diff is collapsed.
......@@ -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_image_factory (void);
......@@ -54,17 +55,11 @@ void menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
gchar *domain_name,
gpointer callback_data);
void menus_reorder_plugins (void);
void menus_quit (void);
void menus_set_sensitive (gchar *path,
gboolean sensitive);
void menus_set_state (gchar *path,
gboolean state);
void menus_destroy (gchar *path);
void menus_last_opened_add (const gchar *filename);
#endif /* __MENUS_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment