Commit 4a199a3e authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

new function which configures the dialog to load an image.

2004-03-01  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpfiledialog.[ch] (gimp_file_dialog_set_uri):
	new function which configures the dialog to load an image.

	* app/gui/file-open-dialog.c: use it. Don't use file-dialog-utils
	any more and allow setting the uri of an already visible file open
	dialog.

	* app/gui/file-dialog-utils.c: took the file open menu entries out
	of that insane logic that makes the menus insensitive while any
	file dialog is open.
parent ca2f7f88
2004-03-01 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpfiledialog.[ch] (gimp_file_dialog_set_uri):
new function which configures the dialog to load an image.
* app/gui/file-open-dialog.c: use it. Don't use file-dialog-utils
any more and allow setting the uri of an already visible file open
dialog.
* app/gui/file-dialog-utils.c: took the file open menu entries out
of that insane logic that makes the menus insensitive while any
file dialog is open.
2004-03-01 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpfiledialog.[ch] (gimp_file_dialog_set_image):
......@@ -32,9 +32,6 @@ void
file_dialog_show (GtkWidget *dialog,
GtkWidget *parent)
{
gimp_item_factories_set_sensitive ("<Toolbox>", "/File/Open...", FALSE);
gimp_item_factories_set_sensitive ("<Image>", "/File/Open...", FALSE);
gimp_item_factories_set_sensitive ("<Image>", "/File/Save", FALSE);
gimp_item_factories_set_sensitive ("<Image>", "/File/Save as...", FALSE);
gimp_item_factories_set_sensitive ("<Image>", "/File/Save a Copy...", FALSE);
......@@ -49,9 +46,6 @@ file_dialog_hide (GtkWidget *dialog)
{
gtk_widget_hide (dialog);
gimp_item_factories_set_sensitive ("<Toolbox>", "/File/Open...", TRUE);
gimp_item_factories_set_sensitive ("<Image>", "/File/Open...", TRUE);
gimp_item_factories_set_sensitive ("<Image>", "/File/Save", TRUE);
gimp_item_factories_set_sensitive ("<Image>", "/File/Save as...", TRUE);
gimp_item_factories_set_sensitive ("<Image>", "/File/Save a Copy...", TRUE);
......
......@@ -39,7 +39,6 @@
#include "widgets/gimpmenufactory.h"
#include "dialogs.h"
#include "file-dialog-utils.h"
#include "file-open-dialog.h"
#include "gimp-intl.h"
......@@ -73,8 +72,6 @@ file_open_dialog_show (Gimp *gimp,
GimpMenuFactory *menu_factory,
GtkWidget *parent)
{
gchar *filename = NULL;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (gimage == NULL || GIMP_IS_IMAGE (gimage));
g_return_if_fail (GIMP_IS_MENU_FACTORY (menu_factory));
......@@ -83,44 +80,15 @@ file_open_dialog_show (Gimp *gimp,
if (! fileload)
fileload = file_open_dialog_create (gimp, menu_factory);
gtk_widget_set_sensitive (GTK_WIDGET (fileload), TRUE);
if (GTK_WIDGET_VISIBLE (fileload))
{
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_window_set_title (GTK_WINDOW (fileload), _("Open Image"));
gimp_file_dialog_set_uri (GIMP_FILE_DIALOG (fileload), gimage, uri);
gtk_file_selection_set_filename (GTK_FILE_SELECTION (fileload),
filename ?
filename :
"." G_DIR_SEPARATOR_S);
if (parent)
gtk_window_set_screen (GTK_WINDOW (fileload),
gtk_widget_get_screen (parent));
g_free (filename);
gtk_widget_grab_focus (GTK_FILE_SELECTION (fileload)->selection_entry);
file_dialog_show (fileload, parent);
gtk_window_present (GTK_WINDOW (fileload));
}
......@@ -164,7 +132,7 @@ file_open_dialog_response (GtkWidget *open_dialog,
if (response_id != GTK_RESPONSE_OK)
{
file_dialog_hide (open_dialog);
gtk_widget_hide (open_dialog);
return;
}
......@@ -214,7 +182,7 @@ file_open_dialog_response (GtkWidget *open_dialog,
entered_filename,
GIMP_FILE_DIALOG (open_dialog)->file_proc))
{
file_dialog_hide (open_dialog);
gtk_widget_hide (open_dialog);
}
g_free (uri);
......@@ -235,7 +203,7 @@ file_open_dialog_response (GtkWidget *open_dialog,
uri,
GIMP_FILE_DIALOG (open_dialog)->file_proc))
{
file_dialog_hide (open_dialog);
gtk_widget_hide (open_dialog);
}
g_free (uri);
......
......@@ -32,9 +32,6 @@ void
file_dialog_show (GtkWidget *dialog,
GtkWidget *parent)
{
gimp_item_factories_set_sensitive ("<Toolbox>", "/File/Open...", FALSE);
gimp_item_factories_set_sensitive ("<Image>", "/File/Open...", FALSE);
gimp_item_factories_set_sensitive ("<Image>", "/File/Save", FALSE);
gimp_item_factories_set_sensitive ("<Image>", "/File/Save as...", FALSE);
gimp_item_factories_set_sensitive ("<Image>", "/File/Save a Copy...", FALSE);
......@@ -49,9 +46,6 @@ file_dialog_hide (GtkWidget *dialog)
{
gtk_widget_hide (dialog);
gimp_item_factories_set_sensitive ("<Toolbox>", "/File/Open...", TRUE);
gimp_item_factories_set_sensitive ("<Image>", "/File/Open...", TRUE);
gimp_item_factories_set_sensitive ("<Image>", "/File/Save", TRUE);
gimp_item_factories_set_sensitive ("<Image>", "/File/Save as...", TRUE);
gimp_item_factories_set_sensitive ("<Image>", "/File/Save a Copy...", TRUE);
......
......@@ -39,7 +39,6 @@
#include "widgets/gimpmenufactory.h"
#include "dialogs.h"
#include "file-dialog-utils.h"
#include "file-open-dialog.h"
#include "gimp-intl.h"
......@@ -73,8 +72,6 @@ file_open_dialog_show (Gimp *gimp,
GimpMenuFactory *menu_factory,
GtkWidget *parent)
{
gchar *filename = NULL;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (gimage == NULL || GIMP_IS_IMAGE (gimage));
g_return_if_fail (GIMP_IS_MENU_FACTORY (menu_factory));
......@@ -83,44 +80,15 @@ file_open_dialog_show (Gimp *gimp,
if (! fileload)
fileload = file_open_dialog_create (gimp, menu_factory);
gtk_widget_set_sensitive (GTK_WIDGET (fileload), TRUE);
if (GTK_WIDGET_VISIBLE (fileload))
{
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_window_set_title (GTK_WINDOW (fileload), _("Open Image"));
gimp_file_dialog_set_uri (GIMP_FILE_DIALOG (fileload), gimage, uri);
gtk_file_selection_set_filename (GTK_FILE_SELECTION (fileload),
filename ?
filename :
"." G_DIR_SEPARATOR_S);
if (parent)
gtk_window_set_screen (GTK_WINDOW (fileload),
gtk_widget_get_screen (parent));
g_free (filename);
gtk_widget_grab_focus (GTK_FILE_SELECTION (fileload)->selection_entry);
file_dialog_show (fileload, parent);
gtk_window_present (GTK_WINDOW (fileload));
}
......@@ -164,7 +132,7 @@ file_open_dialog_response (GtkWidget *open_dialog,
if (response_id != GTK_RESPONSE_OK)
{
file_dialog_hide (open_dialog);
gtk_widget_hide (open_dialog);
return;
}
......@@ -214,7 +182,7 @@ file_open_dialog_response (GtkWidget *open_dialog,
entered_filename,
GIMP_FILE_DIALOG (open_dialog)->file_proc))
{
file_dialog_hide (open_dialog);
gtk_widget_hide (open_dialog);
}
g_free (uri);
......@@ -235,7 +203,7 @@ file_open_dialog_response (GtkWidget *open_dialog,
uri,
GIMP_FILE_DIALOG (open_dialog)->file_proc))
{
file_dialog_hide (open_dialog);
gtk_widget_hide (open_dialog);
}
g_free (uri);
......
......@@ -253,6 +253,43 @@ gimp_file_dialog_set_file_proc (GimpFileDialog *dialog,
}
}
void
gimp_file_dialog_set_uri (GimpFileDialog *dialog,
GimpImage *gimage,
const gchar *uri)
{
gchar *filename = NULL;
g_return_if_fail (GIMP_IS_FILE_DIALOG (dialog));
g_return_if_fail (gimage == NULL || GIMP_IS_IMAGE (gimage));
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, G_DIR_SEPARATOR_S, NULL);
g_free (dirname);
}
}
else if (uri)
{
filename = g_filename_from_uri (uri, NULL, NULL);
}
gtk_file_selection_set_filename (GTK_FILE_SELECTION (dialog),
filename ?
filename : "." G_DIR_SEPARATOR_S);
g_free (filename);
}
void
gimp_file_dialog_set_image (GimpFileDialog *dialog,
GimpImage *gimage,
......
......@@ -70,6 +70,9 @@ GtkWidget * gimp_file_dialog_new (Gimp *gimp,
void gimp_file_dialog_set_file_proc (GimpFileDialog *dialog,
PlugInProcDef *file_proc);
void gimp_file_dialog_set_uri (GimpFileDialog *dialog,
GimpImage *gimage,
const gchar *uri);
void gimp_file_dialog_set_image (GimpFileDialog *dialog,
GimpImage *gimage,
gboolean set_uri_and_proc,
......
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