Commit 94f8431f authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

added "gimage" and "uri" parameters to file_open_dialog_show(). If an

2002-11-01  Michael Natterer  <mitch@gimp.org>

	* app/gui/file-open-dialog.[ch]: added "gimage" and "uri"
	parameters to file_open_dialog_show(). If an image is passed, go
	to that image's directory, for an uri, preselect the file.
	Fixes bug #96779.

	* app/gui/menus.c: pass "action" to file_open_cmd_callback() so we
	can distinguish if it was invoked from the toolbox or an image.

	* app/gui/file-commands.[ch]: if invoked from an image, pass it to
	file_open_dialog_show().

	* app/widgets/gimpdocumentview.c: pass the selected document's uri
	to file_open_dialog_show().

	* app/gui/file-save-dialog.c: use gimp_image_get_filename()
	instead of fiddling with the image's uri manually.
parent 70363efb
2002-11-01 Michael Natterer <mitch@gimp.org>
* app/gui/file-open-dialog.[ch]: added "gimage" and "uri"
parameters to file_open_dialog_show(). If an image is passed, go
to that image's directory, for an uri, preselect the file.
Fixes bug #96779.
* app/gui/menus.c: pass "action" to file_open_cmd_callback() so we
can distinguish if it was invoked from the toolbox or an image.
* app/gui/file-commands.[ch]: if invoked from an image, pass it to
file_open_dialog_show().
* app/widgets/gimpdocumentview.c: pass the selected document's uri
to file_open_dialog_show().
* app/gui/file-save-dialog.c: use gimp_image_get_filename()
instead of fiddling with the image's uri manually.
2002-11-01 Michael Natterer <mitch@gimp.org>
 
* app/widgets/gimpdataeditor.c
......
......@@ -78,25 +78,34 @@ file_new_cmd_callback (GtkWidget *widget,
/* if called from the image menu */
if (action)
{
gimage = gimp_context_get_image (gimp_get_user_context (gimp));
}
gimage = gimp_context_get_image (gimp_get_user_context (gimp));
file_new_dialog_create (gimp, gimage);
}
void
file_open_by_extension_cmd_callback (GtkWidget *widget,
gpointer data)
gpointer data,
guint action)
{
file_open_dialog_menu_reset ();
}
void
file_open_cmd_callback (GtkWidget *widget,
gpointer data)
gpointer data,
guint action)
{
file_open_dialog_show (GIMP (data));
Gimp *gimp;
GimpImage *gimage = NULL;
gimp = GIMP (data);
/* if called from the image menu */
if (action)
gimage = gimp_context_get_image (gimp_get_user_context (gimp));
file_open_dialog_show (gimp, gimage, NULL);
}
void
......@@ -129,14 +138,16 @@ file_last_opened_cmd_callback (GtkWidget *widget,
void
file_save_by_extension_cmd_callback (GtkWidget *widget,
gpointer data)
gpointer data,
guint action)
{
file_save_dialog_menu_reset ();
}
void
file_save_cmd_callback (GtkWidget *widget,
gpointer data)
gpointer data,
guint action)
{
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
......@@ -153,7 +164,7 @@ file_save_cmd_callback (GtkWidget *widget,
if (! uri)
{
file_save_as_cmd_callback (widget, data);
file_save_as_cmd_callback (widget, data, action);
}
else
{
......@@ -178,7 +189,8 @@ file_save_cmd_callback (GtkWidget *widget,
void
file_save_as_cmd_callback (GtkWidget *widget,
gpointer data)
gpointer data,
guint action)
{
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
......@@ -188,7 +200,8 @@ file_save_as_cmd_callback (GtkWidget *widget,
void
file_save_a_copy_cmd_callback (GtkWidget *widget,
gpointer data)
gpointer data,
guint action)
{
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
......@@ -198,7 +211,8 @@ file_save_a_copy_cmd_callback (GtkWidget *widget,
void
file_revert_cmd_callback (GtkWidget *widget,
gpointer data)
gpointer data,
guint action)
{
GimpDisplay *gdisp;
GtkWidget *query_box;
......@@ -256,7 +270,8 @@ file_revert_cmd_callback (GtkWidget *widget,
void
file_close_cmd_callback (GtkWidget *widget,
gpointer data)
gpointer data,
guint action)
{
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
......@@ -266,7 +281,8 @@ file_close_cmd_callback (GtkWidget *widget,
void
file_quit_cmd_callback (GtkWidget *widget,
gpointer data)
gpointer data,
guint action)
{
app_exit (FALSE);
}
......
......@@ -25,30 +25,40 @@ void file_new_cmd_callback (GtkWidget *widget,
guint action);
void file_open_by_extension_cmd_callback (GtkWidget *widget,
gpointer data);
gpointer data,
guint action);
void file_open_cmd_callback (GtkWidget *widget,
gpointer data);
gpointer data,
guint action);
void file_last_opened_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void file_save_by_extension_cmd_callback (GtkWidget *widget,
gpointer data);
gpointer data,
guint action);
void file_save_cmd_callback (GtkWidget *widget,
gpointer data);
gpointer data,
guint action);
void file_save_as_cmd_callback (GtkWidget *widget,
gpointer data);
gpointer data,
guint action);
void file_save_a_copy_cmd_callback (GtkWidget *widget,
gpointer data);
gpointer data,
guint action);
void file_revert_cmd_callback (GtkWidget *widget,
gpointer data);
gpointer data,
guint action);
void file_pref_cmd_callback (GtkWidget *widget,
gpointer data);
gpointer data,
guint action);
void file_close_cmd_callback (GtkWidget *widget,
gpointer data);
gpointer data,
guint action);
void file_quit_cmd_callback (GtkWidget *widget,
gpointer data);
gpointer data,
guint action);
#endif /* __FILE_COMMANDS_H__ */
......@@ -165,21 +165,55 @@ file_open_dialog_menu_reset (void)
}
void
file_open_dialog_show (Gimp *gimp)
file_open_dialog_show (Gimp *gimp,
GimpImage *gimage,
const gchar *uri)
{
gchar *filename = NULL;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (gimage == NULL || GIMP_IS_IMAGE (gimage));
if (! fileload)
fileload = file_open_dialog_create (gimp);
gtk_widget_set_sensitive (GTK_WIDGET (fileload), TRUE);
if (GTK_WIDGET_VISIBLE (fileload))
return;
{
gtk_window_present (GTK_WINDOW (fileload));
return;
}
if (gimage)
{
filename = gimp_image_get_filename (gimage);
if (filename)
{
gchar *dirname;
dirname = g_path_get_dirname (filename);
g_free (filename);
filename = g_build_filename (dirname, ".", NULL);
g_free (dirname);
}
}
else if (uri)
{
filename = g_filename_from_uri (uri, NULL, NULL);
}
gtk_file_selection_set_filename (GTK_FILE_SELECTION (fileload),
"." G_DIR_SEPARATOR_S);
gtk_window_set_title (GTK_WINDOW (fileload), _("Open Image"));
gtk_file_selection_set_filename (GTK_FILE_SELECTION (fileload),
filename ?
filename :
"." G_DIR_SEPARATOR_S);
g_free (filename);
file_dialog_show (fileload);
}
......
......@@ -24,7 +24,9 @@ void file_open_dialog_menu_init (Gimp *gimp,
GimpItemFactory *item_factory);
void file_open_dialog_menu_reset (void);
void file_open_dialog_show (Gimp *gimp);
void file_open_dialog_show (Gimp *gimp,
GimpImage *gimage,
const gchar *uri);
#endif /* __FILE_OPEN_DIALOG_H__ */
......@@ -148,8 +148,7 @@ file_save_dialog_menu_reset (void)
void
file_save_dialog_show (GimpImage *gimage)
{
const gchar *uri;
gchar *filename = NULL;
gchar *filename;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
......@@ -159,25 +158,28 @@ file_save_dialog_show (GimpImage *gimage)
the_gimage = gimage;
set_uri = TRUE;
uri = gimp_object_get_name (GIMP_OBJECT (gimage));
if (uri)
filename = g_filename_from_uri (uri, NULL, NULL);
if (! filesave)
filesave = file_save_dialog_create (gimage->gimp);
gtk_widget_set_sensitive (GTK_WIDGET (filesave), TRUE);
if (GTK_WIDGET_VISIBLE (filesave))
return;
{
gtk_window_present (GTK_WINDOW (filesave));
return;
}
gtk_window_set_title (GTK_WINDOW (filesave), _("Save Image"));
filename = gimp_image_get_filename (gimage);
gtk_file_selection_set_filename (GTK_FILE_SELECTION (filesave),
filename ?
filename :
"." G_DIR_SEPARATOR_S);
g_free (filename);
file_dialog_update_menus (gimage->gimp->save_procs,
gimp_drawable_type (gimp_image_active_drawable (gimage)));
......@@ -207,8 +209,12 @@ file_save_a_copy_dialog_show (GimpImage *gimage)
filesave = file_save_dialog_create (gimage->gimp);
gtk_widget_set_sensitive (GTK_WIDGET (filesave), TRUE);
if (GTK_WIDGET_VISIBLE (filesave))
return;
{
gtk_window_present (GTK_WINDOW (filesave));
return;
}
gtk_window_set_title (GTK_WINDOW (filesave), _("Save a Copy of the Image"));
......
......@@ -78,25 +78,34 @@ file_new_cmd_callback (GtkWidget *widget,
/* if called from the image menu */
if (action)
{
gimage = gimp_context_get_image (gimp_get_user_context (gimp));
}
gimage = gimp_context_get_image (gimp_get_user_context (gimp));
file_new_dialog_create (gimp, gimage);
}
void
file_open_by_extension_cmd_callback (GtkWidget *widget,
gpointer data)
gpointer data,
guint action)
{
file_open_dialog_menu_reset ();
}
void
file_open_cmd_callback (GtkWidget *widget,
gpointer data)
gpointer data,
guint action)
{
file_open_dialog_show (GIMP (data));
Gimp *gimp;
GimpImage *gimage = NULL;
gimp = GIMP (data);
/* if called from the image menu */
if (action)
gimage = gimp_context_get_image (gimp_get_user_context (gimp));
file_open_dialog_show (gimp, gimage, NULL);
}
void
......@@ -129,14 +138,16 @@ file_last_opened_cmd_callback (GtkWidget *widget,
void
file_save_by_extension_cmd_callback (GtkWidget *widget,
gpointer data)
gpointer data,
guint action)
{
file_save_dialog_menu_reset ();
}
void
file_save_cmd_callback (GtkWidget *widget,
gpointer data)
gpointer data,
guint action)
{
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
......@@ -153,7 +164,7 @@ file_save_cmd_callback (GtkWidget *widget,
if (! uri)
{
file_save_as_cmd_callback (widget, data);
file_save_as_cmd_callback (widget, data, action);
}
else
{
......@@ -178,7 +189,8 @@ file_save_cmd_callback (GtkWidget *widget,
void
file_save_as_cmd_callback (GtkWidget *widget,
gpointer data)
gpointer data,
guint action)
{
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
......@@ -188,7 +200,8 @@ file_save_as_cmd_callback (GtkWidget *widget,
void
file_save_a_copy_cmd_callback (GtkWidget *widget,
gpointer data)
gpointer data,
guint action)
{
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
......@@ -198,7 +211,8 @@ file_save_a_copy_cmd_callback (GtkWidget *widget,
void
file_revert_cmd_callback (GtkWidget *widget,
gpointer data)
gpointer data,
guint action)
{
GimpDisplay *gdisp;
GtkWidget *query_box;
......@@ -256,7 +270,8 @@ file_revert_cmd_callback (GtkWidget *widget,
void
file_close_cmd_callback (GtkWidget *widget,
gpointer data)
gpointer data,
guint action)
{
GimpDisplay *gdisp;
return_if_no_display (gdisp, data);
......@@ -266,7 +281,8 @@ file_close_cmd_callback (GtkWidget *widget,
void
file_quit_cmd_callback (GtkWidget *widget,
gpointer data)
gpointer data,
guint action)
{
app_exit (FALSE);
}
......
......@@ -25,30 +25,40 @@ void file_new_cmd_callback (GtkWidget *widget,
guint action);
void file_open_by_extension_cmd_callback (GtkWidget *widget,
gpointer data);
gpointer data,
guint action);
void file_open_cmd_callback (GtkWidget *widget,
gpointer data);
gpointer data,
guint action);
void file_last_opened_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void file_save_by_extension_cmd_callback (GtkWidget *widget,
gpointer data);
gpointer data,
guint action);
void file_save_cmd_callback (GtkWidget *widget,
gpointer data);
gpointer data,
guint action);
void file_save_as_cmd_callback (GtkWidget *widget,
gpointer data);
gpointer data,
guint action);
void file_save_a_copy_cmd_callback (GtkWidget *widget,
gpointer data);
gpointer data,
guint action);
void file_revert_cmd_callback (GtkWidget *widget,
gpointer data);
gpointer data,
guint action);
void file_pref_cmd_callback (GtkWidget *widget,
gpointer data);
gpointer data,
guint action);
void file_close_cmd_callback (GtkWidget *widget,
gpointer data);
gpointer data,
guint action);
void file_quit_cmd_callback (GtkWidget *widget,
gpointer data);
gpointer data,
guint action);
#endif /* __FILE_COMMANDS_H__ */
......@@ -165,21 +165,55 @@ file_open_dialog_menu_reset (void)
}
void
file_open_dialog_show (Gimp *gimp)
file_open_dialog_show (Gimp *gimp,
GimpImage *gimage,
const gchar *uri)
{
gchar *filename = NULL;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (gimage == NULL || GIMP_IS_IMAGE (gimage));
if (! fileload)
fileload = file_open_dialog_create (gimp);
gtk_widget_set_sensitive (GTK_WIDGET (fileload), TRUE);
if (GTK_WIDGET_VISIBLE (fileload))
return;
{
gtk_window_present (GTK_WINDOW (fileload));
return;
}
if (gimage)
{
filename = gimp_image_get_filename (gimage);
if (filename)
{
gchar *dirname;
dirname = g_path_get_dirname (filename);
g_free (filename);
filename = g_build_filename (dirname, ".", NULL);
g_free (dirname);
}
}
else if (uri)
{
filename = g_filename_from_uri (uri, NULL, NULL);
}
gtk_file_selection_set_filename (GTK_FILE_SELECTION (fileload),
"." G_DIR_SEPARATOR_S);
gtk_window_set_title (GTK_WINDOW (fileload), _("Open Image"));
gtk_file_selection_set_filename (GTK_FILE_SELECTION (fileload),
filename ?
filename :
"." G_DIR_SEPARATOR_S);
g_free (filename);
file_dialog_show (fileload);
}
......
......@@ -24,7 +24,9 @@ void file_open_dialog_menu_init (Gimp *gimp,
GimpItemFactory *item_factory);
void file_open_dialog_menu_reset (void);
void file_open_dialog_show (Gimp *gimp);
void file_open_dialog_show (Gimp *gimp,
GimpImage *gimage,
const gchar *uri);
#endif /* __FILE_OPEN_DIALOG_H__ */
......@@ -148,8 +148,7 @@ file_save_dialog_menu_reset (void)
void
file_save_dialog_show (GimpImage *gimage)
{
const gchar *uri;
gchar *filename = NULL;
gchar *filename;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
......@@ -159,25 +158,28 @@ file_save_dialog_show (GimpImage *gimage)
the_gimage = gimage;
set_uri = TRUE;
uri = gimp_object_get_name (GIMP_OBJECT (gimage));
if (uri)
filename = g_filename_from_uri (uri, NULL, NULL);
if (! filesave)
filesave = file_save_dialog_create (gimage->gimp);
gtk_widget_set_sensitive (GTK_WIDGET (filesave), TRUE);
if (GTK_WIDGET_VISIBLE (filesave))
return;
{
gtk_window_present (GTK_WINDOW (filesave));
return;
}
gtk_window_set_title (GTK_WINDOW (filesave), _("Save Image"));
filename = gimp_image_get_filename (gimage);
gtk_file_selection_set_filename (GTK_FILE_SELECTION (filesave),
filename ?
filename :
"." G_DIR_SEPARATOR_S);
g_free (filename);
file_dialog_update_menus (gimage->gimp->save_procs,
gimp_drawable_type (gimp_image_active_drawable (gimage)));
......@@ -207,8 +209,12 @@ file_save_a_copy_dialog_show (GimpImage *gimage)
filesave = file_save_dialog_create (gimage->gimp);
gtk_widget_set_sensitive (GTK_WIDGET (filesave), TRUE);
if (GTK_WIDGET_VISIBLE (filesave))
return;
{
gtk_window_present (GTK_WINDOW (filesave));
return;
}
gtk_window_set_title (GTK_WINDOW (filesave), _("Save a Copy of the Image"));
......
......@@ -308,7 +308,7 @@ static GimpItemFactoryEntry image_entries[] =
NULL,
"file/dialogs/file_new.html", NULL },
{ { N_("/File/Open..."), "<control>O",
file_open_cmd_callback, 0,
file_open_cmd_callback, 1,
"<StockItem>", GTK_STOCK_OPEN },
NULL,
"file/dialogs/file_open.html", NULL },
......
......@@ -308,7 +308,7 @@ static GimpItemFactoryEntry image_entries[] =
NULL,