diff --git a/ChangeLog b/ChangeLog index da1dcde2e1..fb1fd9023b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2004-05-13 Michael Natterer + + * app/menus/Makefile.am: added file-menu.[ch] and + file-dialog-menu.[ch] + + * app/menus/menus.[ch]: removed menus_open_recent_add()... + + * app/menus/file-menu.[ch]: ...and added it here as file_menu_setup(). + + * app/menus/image-menu.c + * app/menus/toolbox-menu.c: changed accordingly. + + * app/menus/file-dialog-menu.[ch]: added factored out code from the + file-open and file-save menus as file_dialog_menu_setup(). + + * app/menus/file-open-menu.c + * app/menus/file-save-menu.c: call file_dialog_menu_setup(). + 2004-05-12 Michael Natterer * app/actions/documents-actions.c diff --git a/app/menus/Makefile.am b/app/menus/Makefile.am index c0f0368b07..72f19ae3e5 100644 --- a/app/menus/Makefile.am +++ b/app/menus/Makefile.am @@ -7,6 +7,10 @@ libappmenus_a_SOURCES = \ menus.c \ menus.h \ \ + file-dialog-menu.c \ + file-dialog-menu.h \ + file-menu.c \ + file-menu.h \ file-open-menu.c \ file-open-menu.h \ file-save-menu.c \ diff --git a/app/menus/file-dialog-menu.c b/app/menus/file-dialog-menu.c new file mode 100644 index 0000000000..d090e312cc --- /dev/null +++ b/app/menus/file-dialog-menu.c @@ -0,0 +1,64 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 + +#include + +#include "menus-types.h" + +#include "plug-in/plug-in-proc.h" + +#include "widgets/gimpuimanager.h" + +#include "file-dialog-menu.h" + + +void +file_dialog_menu_setup (GimpUIManager *manager, + const gchar *ui_path, + GSList *file_procs, + const gchar *xcf_proc_name) +{ + GSList *list; + guint merge_id; + + merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (manager)); + + for (list = file_procs; list; list = g_slist_next (list)) + { + PlugInProcDef *file_proc = list->data; + gchar *path; + + if (! strcmp (file_proc->db_info.name, xcf_proc_name)) + path = g_strdup_printf ("%s/%s", ui_path, "Internal"); + else + path = g_strdup (ui_path); + + gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id, + path, + file_proc->db_info.name, + file_proc->db_info.name, + GTK_UI_MANAGER_MENUITEM, + FALSE); + + g_free (path); + } +} diff --git a/app/menus/file-dialog-menu.h b/app/menus/file-dialog-menu.h new file mode 100644 index 0000000000..084abffca3 --- /dev/null +++ b/app/menus/file-dialog-menu.h @@ -0,0 +1,29 @@ +/* The GIMP -- an open manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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. + */ + +#ifndef __FILE_DIALOG_MENU_H__ +#define __FILE_DIALOG_MENU_H__ + + +void file_dialog_menu_setup (GimpUIManager *manager, + const gchar *ui_path, + GSList *file_procs, + const gchar *xcf_proc_name); + + +#endif /* __FILE_DIALOG_MENU_H__ */ diff --git a/app/menus/file-menu.c b/app/menus/file-menu.c new file mode 100644 index 0000000000..3a2a1a58c2 --- /dev/null +++ b/app/menus/file-menu.c @@ -0,0 +1,65 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 + +#include "menus-types.h" + +#include "config/gimpguiconfig.h" + +#include "core/gimp.h" + +#include "widgets/gimpuimanager.h" + +#include "file-menu.h" + + +void +file_menu_setup (GimpUIManager *manager, + const gchar *ui_path) +{ + gint n_entries; + guint merge_id; + gint i; + + g_return_if_fail (GIMP_IS_UI_MANAGER (manager)); + g_return_if_fail (ui_path != NULL); + + n_entries = GIMP_GUI_CONFIG (manager->gimp->config)->last_opened_size; + + merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (manager)); + + for (i = 0; i < n_entries; i++) + { + gchar *action_name; + gchar *action_path; + + action_name = g_strdup_printf ("file-open-recent-%02d", i + 1); + action_path = g_strdup_printf ("%s/File/Open Recent/Files", ui_path); + + gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id, + action_path, action_name, action_name, + GTK_UI_MANAGER_MENUITEM, + FALSE); + + g_free (action_name); + g_free (action_path); + } +} diff --git a/app/menus/file-menu.h b/app/menus/file-menu.h new file mode 100644 index 0000000000..7482de42e9 --- /dev/null +++ b/app/menus/file-menu.h @@ -0,0 +1,27 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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. + */ + +#ifndef __FILE_MENU_H__ +#define __FILE_MENU_H__ + + +void file_menu_setup (GimpUIManager *manager, + const gchar *ui_path); + + +#endif /* __FILE_MENU_H__ */ diff --git a/app/menus/file-open-menu.c b/app/menus/file-open-menu.c index 1504d374ab..4819061915 100644 --- a/app/menus/file-open-menu.c +++ b/app/menus/file-open-menu.c @@ -18,18 +18,15 @@ #include "config.h" -#include - #include #include "menus-types.h" #include "core/gimp.h" -#include "plug-in/plug-in-proc.h" - #include "widgets/gimpuimanager.h" +#include "file-dialog-menu.h" #include "file-open-menu.h" @@ -37,28 +34,7 @@ void file_open_menu_setup (GimpUIManager *manager, const gchar *ui_path) { - GSList *list; - guint merge_id; - - merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (manager)); - - for (list = manager->gimp->load_procs; list; list = g_slist_next (list)) - { - PlugInProcDef *file_proc = list->data; - gchar *path; - - if (! strcmp (file_proc->db_info.name, "gimp_xcf_load")) - path = g_strdup_printf ("%s/%s", ui_path, "Internal"); - else - path = g_strdup (ui_path); - - gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id, - path, - file_proc->db_info.name, - file_proc->db_info.name, - GTK_UI_MANAGER_MENUITEM, - FALSE); - - g_free (path); - } + file_dialog_menu_setup (manager, ui_path, + manager->gimp->load_procs, + "gimp_xcf_load"); } diff --git a/app/menus/file-save-menu.c b/app/menus/file-save-menu.c index 6b508f8e69..3aa28a2b2d 100644 --- a/app/menus/file-save-menu.c +++ b/app/menus/file-save-menu.c @@ -18,18 +18,15 @@ #include "config.h" -#include - #include #include "menus-types.h" #include "core/gimp.h" -#include "plug-in/plug-in-proc.h" - #include "widgets/gimpuimanager.h" +#include "file-dialog-menu.h" #include "file-save-menu.h" @@ -37,28 +34,7 @@ void file_save_menu_setup (GimpUIManager *manager, const gchar *ui_path) { - GSList *list; - guint merge_id; - - merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (manager)); - - for (list = manager->gimp->save_procs; list; list = g_slist_next (list)) - { - PlugInProcDef *file_proc = list->data; - gchar *path; - - if (! strcmp (file_proc->db_info.name, "gimp_xcf_save")) - path = g_strdup_printf ("%s/%s", ui_path, "Internal"); - else - path = g_strdup (ui_path); - - gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id, - path, - file_proc->db_info.name, - file_proc->db_info.name, - GTK_UI_MANAGER_MENUITEM, - FALSE); - - g_free (path); - } + file_dialog_menu_setup (manager, ui_path, + manager->gimp->save_procs, + "gimp_xcf_save"); } diff --git a/app/menus/image-menu.c b/app/menus/image-menu.c index 1e0cd8719a..9025beeae1 100644 --- a/app/menus/image-menu.c +++ b/app/menus/image-menu.c @@ -22,8 +22,8 @@ #include "menus-types.h" +#include "file-menu.h" #include "image-menu.h" -#include "menus.h" #include "plug-in-menus.h" @@ -31,6 +31,6 @@ void image_menu_setup (GimpUIManager *manager, const gchar *ui_path) { - menus_open_recent_add (manager, ui_path); + file_menu_setup (manager, ui_path); plug_in_menus_setup (manager, ui_path); } diff --git a/app/menus/menus.c b/app/menus/menus.c index 3cccfd96af..3f5e728a00 100644 --- a/app/menus/menus.c +++ b/app/menus/menus.c @@ -21,21 +21,14 @@ #include #include "libgimpbase/gimpbase.h" -#include "libgimpwidgets/gimpwidgets.h" #include "menus-types.h" #include "config/gimpguiconfig.h" #include "core/gimp.h" -#include "core/gimpcontainer.h" -#include "core/gimpcontext.h" -#include "file/file-utils.h" - -#include "widgets/gimphelp-ids.h" #include "widgets/gimpmenufactory.h" -#include "widgets/gimpuimanager.h" #include "actions/actions.h" @@ -334,39 +327,6 @@ menus_clear (Gimp *gimp) g_print ("TODO: implement menus_clear()\n"); } -void -menus_open_recent_add (GimpUIManager *manager, - const gchar *ui_path) -{ - gint n_entries; - guint merge_id; - gint i; - - g_return_if_fail (GIMP_IS_UI_MANAGER (manager)); - g_return_if_fail (ui_path != NULL); - - n_entries = GIMP_GUI_CONFIG (manager->gimp->config)->last_opened_size; - - merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (manager)); - - for (i = 0; i < n_entries; i++) - { - gchar *action_name; - gchar *action_path; - - action_name = g_strdup_printf ("file-open-recent-%02d", i + 1); - action_path = g_strdup_printf ("%s/File/Open Recent/Files", ui_path); - - gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id, - action_path, action_name, action_name, - GTK_UI_MANAGER_MENUITEM, - FALSE); - - g_free (action_name); - g_free (action_path); - } -} - /* private functions */ diff --git a/app/menus/menus.h b/app/menus/menus.h index 3e1e49a311..af18e17b27 100644 --- a/app/menus/menus.h +++ b/app/menus/menus.h @@ -23,14 +23,11 @@ extern GimpMenuFactory *global_menu_factory; -void menus_init (Gimp *gimp); -void menus_exit (Gimp *gimp); -void menus_restore (Gimp *gimp); -void menus_save (Gimp *gimp); -void menus_clear (Gimp *gimp); - -void menus_open_recent_add (GimpUIManager *manager, - const gchar *ui_path); +void menus_init (Gimp *gimp); +void menus_exit (Gimp *gimp); +void menus_restore (Gimp *gimp); +void menus_save (Gimp *gimp); +void menus_clear (Gimp *gimp); #endif /* __MENUS_H__ */ diff --git a/app/menus/toolbox-menu.c b/app/menus/toolbox-menu.c index 9a8a8b6413..aa2a953c64 100644 --- a/app/menus/toolbox-menu.c +++ b/app/menus/toolbox-menu.c @@ -22,7 +22,7 @@ #include "menus-types.h" -#include "menus.h" +#include "file-menu.h" #include "plug-in-menus.h" #include "toolbox-menu.h" @@ -31,6 +31,6 @@ void toolbox_menu_setup (GimpUIManager *manager, const gchar *ui_path) { - menus_open_recent_add (manager, ui_path); + file_menu_setup (manager, ui_path); plug_in_menus_setup (manager, ui_path); }