mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-21 12:02:32 +00:00
47c5473e46
2002-03-20 Michael Natterer <mitch@gimp.org> * app/plug-in/plug-in.[ch]: badly chopped into the new files below. Pass around much more "PlugIn" and "Gimp" pointers instead of using "current_plug_in" and "the_gimp". Needs much more hacking though... :( * app/plug-in/Makefile.am * app/plug-in/plug-in-def.[ch] * app/plug-in/plug-in-params.[ch] * app/plug-in/plug-in-progress.[ch] * app/plug-in/plug-ins.[ch]: new files. * app/gui/Makefile.am * app/gui/plug-in-commands.[ch] * app/gui/plug-in-menus.[ch]: ditto. * app/plug-in/plug-in-rc.c * app/plug-in/plug-in-types.h: changed accordingly. * app/pdb/procedural_db.c: changed procedural_db_destroy_args() so it can be used from plug_in_args_destroy(). Fixed a parasite memory leak (or introduced a new SEGV, we'll see...). * app/display/Makefile.am: another "truly ugly hack" until the plug-in menu stuff is chopped even more... * app/gui/commands.[ch]: removed filters_repeat_cmd_callback() here, it is now in plug-in-commands.[ch]. * app/widgets/gimpitemfactory.[ch]: removed all gimp_menu_item_*() hacks. We have a GimpItemFactory available in most cases we used to call this functions, and can use gimp_item_factors_from_path() in all other cases. The item factory stuff needs more work anyway... * app/app_procs.c * app/gimphelp.c * app/display/gimpdisplayshell.c * app/gui/file-dialog-utils.c * app/gui/file-open-dialog.[ch] * app/gui/file-save-dialog.[ch] * app/gui/gui.c * app/gui/menus.c * app/gui/paths-dialog.c * app/xcf/xcf.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/plug_in.pdb: changed accordingly (includes, renamed functions and gimp_menu_item_*() removal). * app/pdb/fileops_cmds.c * app/pdb/help_cmds.c * app/pdb/plug_in_cmds.c: regenerated.
152 lines
4.4 KiB
C
152 lines
4.4 KiB
C
/* The GIMP -- an image manipulation program
|
|
* Copyright (C) 1995, 1996, 1997 Spencer Kimball and Peter Mattis
|
|
* Copyright (C) 1997 Josh MacDonald
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
#include <string.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include "gui-types.h"
|
|
|
|
#include "plug-in/plug-in-proc.h"
|
|
|
|
#include "widgets/gimpitemfactory.h"
|
|
|
|
#include "file-dialog-utils.h"
|
|
|
|
|
|
void
|
|
file_dialog_show (GtkWidget *filesel)
|
|
{
|
|
GtkItemFactory *item_factory;
|
|
|
|
item_factory = GTK_ITEM_FACTORY (gimp_item_factory_from_path ("<Toolbox>"));
|
|
gimp_item_factory_set_sensitive (item_factory, "/File/Open...", FALSE);
|
|
|
|
item_factory = GTK_ITEM_FACTORY (gimp_item_factory_from_path ("<Image>"));
|
|
gimp_item_factory_set_sensitive (item_factory, "/File/Open...", FALSE);
|
|
gimp_item_factory_set_sensitive (item_factory, "/File/Save", FALSE);
|
|
gimp_item_factory_set_sensitive (item_factory, "/File/Save as...", FALSE);
|
|
gimp_item_factory_set_sensitive (item_factory, "/File/Save a Copy as...", FALSE);
|
|
|
|
gtk_widget_grab_focus (GTK_FILE_SELECTION (filesel)->selection_entry);
|
|
gtk_widget_show (filesel);
|
|
}
|
|
|
|
gboolean
|
|
file_dialog_hide (GtkWidget *filesel)
|
|
{
|
|
GtkItemFactory *item_factory;
|
|
|
|
gtk_widget_hide (filesel);
|
|
|
|
item_factory = GTK_ITEM_FACTORY (gimp_item_factory_from_path ("<Toolbox>"));
|
|
gimp_item_factory_set_sensitive (item_factory, "/File/Open...", TRUE);
|
|
|
|
item_factory = GTK_ITEM_FACTORY (gimp_item_factory_from_path ("<Image>"));
|
|
gimp_item_factory_set_sensitive (item_factory, "/File/Open...", TRUE);
|
|
gimp_item_factory_set_sensitive (item_factory, "/File/Save", TRUE);
|
|
gimp_item_factory_set_sensitive (item_factory, "/File/Save as...", TRUE);
|
|
gimp_item_factory_set_sensitive (item_factory, "/File/Save a Copy as...", TRUE);
|
|
|
|
/* return TRUE because we are used as "delete_event" handler */
|
|
return TRUE;
|
|
}
|
|
|
|
void
|
|
file_dialog_update_name (PlugInProcDef *proc,
|
|
GtkFileSelection *filesel)
|
|
{
|
|
if (proc->extensions_list)
|
|
{
|
|
const gchar *text;
|
|
gchar *last_dot;
|
|
GString *s;
|
|
|
|
text = gtk_entry_get_text (GTK_ENTRY (filesel->selection_entry));
|
|
last_dot = strrchr (text, '.');
|
|
|
|
if (last_dot == text || !text[0])
|
|
return;
|
|
|
|
s = g_string_new (text);
|
|
|
|
if (last_dot)
|
|
g_string_truncate (s, last_dot-text);
|
|
|
|
g_string_append (s, ".");
|
|
g_string_append (s, (gchar *) proc->extensions_list->data);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (filesel->selection_entry), s->str);
|
|
|
|
g_string_free (s, TRUE);
|
|
}
|
|
}
|
|
|
|
void
|
|
file_dialog_update_menus (GSList *procs,
|
|
GimpImageType image_type)
|
|
{
|
|
PlugInProcDef *file_proc;
|
|
PlugInImageType plug_in_image_type = 0;
|
|
|
|
switch (image_type)
|
|
{
|
|
case GIMP_RGB_IMAGE:
|
|
plug_in_image_type = PLUG_IN_RGB_IMAGE;
|
|
break;
|
|
case GIMP_RGBA_IMAGE:
|
|
plug_in_image_type = PLUG_IN_RGBA_IMAGE;
|
|
break;
|
|
case GIMP_GRAY_IMAGE:
|
|
plug_in_image_type = PLUG_IN_GRAY_IMAGE;
|
|
break;
|
|
case GIMP_GRAYA_IMAGE:
|
|
plug_in_image_type = PLUG_IN_GRAYA_IMAGE;
|
|
break;
|
|
case GIMP_INDEXED_IMAGE:
|
|
plug_in_image_type = PLUG_IN_INDEXED_IMAGE;
|
|
break;
|
|
case GIMP_INDEXEDA_IMAGE:
|
|
plug_in_image_type = PLUG_IN_INDEXEDA_IMAGE;
|
|
break;
|
|
default:
|
|
g_assert_not_reached ();
|
|
break;
|
|
}
|
|
|
|
for (; procs; procs = g_slist_next (procs))
|
|
{
|
|
file_proc = (PlugInProcDef *) procs->data;
|
|
|
|
if (file_proc->db_info.proc_type != GIMP_EXTENSION)
|
|
{
|
|
GtkItemFactory *item_factory;
|
|
|
|
item_factory =
|
|
GTK_ITEM_FACTORY (gimp_item_factory_from_path (file_proc->menu_path));
|
|
|
|
gimp_item_factory_set_sensitive (item_factory,
|
|
file_proc->menu_path,
|
|
(file_proc->image_types_val & plug_in_image_type));
|
|
}
|
|
}
|
|
}
|