app/actions/Makefile.am new files containing factored out code to set up

2004-05-02  Michael Natterer  <mitch@convergence.de>

	* app/actions/Makefile.am
	* app/actions/file-dialog-actions.[ch]: new files containing
	factored out code to set up the <Load> and <Save> actions.
	Use GimpPlugInActions instead of just GtkActions.

	* app/actions/file-dialog-commands.[ch]: new files containing
	file_dialog_type_cmd_callback() which is a
	GimpPlugInAction::selected() callback now.

	* app/actions/file-commands.[ch]: removed the callback here.

	* app/actions/file-open-actions.c
	* app/actions/file-save-actions.c: removed code duplication and
	use file_dialog_actions_setup() instead.
This commit is contained in:
Michael Natterer 2004-05-02 10:34:04 +00:00 committed by Michael Natterer
parent 9377b26ebc
commit bdec5cc5da
10 changed files with 232 additions and 127 deletions

View File

@ -1,3 +1,20 @@
2004-05-02 Michael Natterer <mitch@convergence.de>
* app/actions/Makefile.am
* app/actions/file-dialog-actions.[ch]: new files containing
factored out code to set up the <Load> and <Save> actions.
Use GimpPlugInActions instead of just GtkActions.
* app/actions/file-dialog-commands.[ch]: new files containing
file_dialog_type_cmd_callback() which is a
GimpPlugInAction::selected() callback now.
* app/actions/file-commands.[ch]: removed the callback here.
* app/actions/file-open-actions.c
* app/actions/file-save-actions.c: removed code duplication and
use file_dialog_actions_setup() instead.
2004-05-02 Michael Natterer <mitch@gimp.org>
* app/actions/*-actions.c: added help IDs to all actions

View File

@ -55,6 +55,10 @@ libappactions_a_SOURCES = \
file-actions.h \
file-commands.c \
file-commands.h \
file-dialog-actions.c \
file-dialog-actions.h \
file-dialog-commands.c \
file-dialog-commands.h \
file-open-actions.c \
file-open-actions.h \
file-save-actions.c \

View File

@ -42,7 +42,6 @@
#include "widgets/gimpdock.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpfiledialog.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplay-foreach.h"
@ -136,15 +135,6 @@ file_new_cmd_callback (GtkAction *action,
file_new_dialog_set (dialog, gimage, NULL);
}
void
file_type_cmd_callback (GtkAction *action,
gpointer data)
{
gimp_file_dialog_set_file_proc (GIMP_FILE_DIALOG (data),
g_object_get_data (G_OBJECT (action),
"file-proc"));
}
void
file_open_cmd_callback (GtkAction *action,
gpointer data)

View File

@ -20,10 +20,8 @@
#define __FILE_COMMANDS_H__
void file_new_cmd_callback (GtkAction *action,
gpointer data);
void file_type_cmd_callback (GtkAction *action,
void file_new_cmd_callback (GtkAction *action,
gpointer data);
void file_open_cmd_callback (GtkAction *action,

View File

@ -0,0 +1,92 @@
/* 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 <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "actions-types.h"
#include "plug-in/plug-in-proc.h"
#include "plug-in/plug-ins.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
#include "file-dialog-commands.h"
#include "file-dialog-actions.h"
#include "gimp-intl.h"
void
file_dialog_actions_setup (GimpActionGroup *group,
GSList *file_procs,
const gchar *xcf_proc_name)
{
GSList *list;
for (list = file_procs; list; list = g_slist_next (list))
{
PlugInProcDef *file_proc = list->data;
const gchar *stock_id = NULL;
gchar *help_id;
GimpPlugInActionEntry entry;
gboolean is_xcf;
if (! file_proc->menu_path)
continue;
is_xcf = (strcmp (file_proc->db_info.name, xcf_proc_name) == 0);
if (is_xcf)
{
stock_id = GIMP_STOCK_WILBER;
help_id = g_strdup (GIMP_HELP_FILE_SAVE_XCF);
}
else
{
const gchar *progname;
const gchar *locale_domain;
const gchar *help_domain;
progname = plug_in_proc_def_get_progname (file_proc);
locale_domain = plug_ins_locale_domain (group->gimp, progname, NULL);
help_domain = plug_ins_help_domain (group->gimp, progname, NULL);
help_id = plug_in_proc_def_get_help_id (file_proc, help_domain);
}
entry.name = file_proc->db_info.name;
entry.stock_id = stock_id;
entry.label = strstr (file_proc->menu_path, "/") + 1;
entry.tooltip = NULL;
entry.proc_def = file_proc;
entry.help_id = help_id;
gimp_action_group_add_plug_in_actions (group, &entry, 1,
G_CALLBACK (file_dialog_type_cmd_callback));
g_free (help_id);
}
}

View File

@ -0,0 +1,28 @@
/* 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_DIALOG_ACTIONS_H__
#define __FILE_DIALOG_ACTIONS_H__
void file_dialog_actions_setup (GimpActionGroup *group,
GSList *file_procs,
const gchar *xcf_proc_name);
#endif /* __FILE_DIALOG_ACTIONS_H__ */

View File

@ -0,0 +1,38 @@
/* 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 <gtk/gtk.h>
#include "actions-types.h"
#include "widgets/gimpfiledialog.h"
#include "file-dialog-commands.h"
/* public functions */
void
file_dialog_type_cmd_callback (GtkAction *action,
PlugInProcDef *proc_def,
gpointer data)
{
gimp_file_dialog_set_file_proc (GIMP_FILE_DIALOG (data), proc_def);
}

View File

@ -0,0 +1,28 @@
/* 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_DIALOG_COMMANDS_H__
#define __FILE_DIALOG_COMMANDS_H__
void file_dialog_type_cmd_callback (GtkAction *action,
PlugInProcDef *proc_def,
gpointer data);
#endif /* __FILE_DIALOG_COMMANDS_H__ */

View File

@ -27,15 +27,12 @@
#include "actions-types.h"
#include "core/gimp.h"
#include "core/gimpdrawable.h"
#include "plug-in/plug-in-proc.h"
#include "plug-in/plug-ins.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
#include "file-commands.h"
#include "file-dialog-actions.h"
#include "file-dialog-commands.h"
#include "file-open-actions.h"
#include "gimp-intl.h"
@ -44,11 +41,14 @@
static GimpActionEntry file_open_actions[] =
{
{ "file-open-popup", NULL, N_("File Open Menu"), NULL, NULL, NULL,
GIMP_HELP_FILE_OPEN },
GIMP_HELP_FILE_OPEN }
};
static GimpPlugInActionEntry file_open_file_type_actions[] =
{
{ "file-open-automatic", NULL,
N_("Automatic"), NULL, NULL,
G_CALLBACK (file_type_cmd_callback),
NULL,
GIMP_HELP_FILE_OPEN_BY_EXTENSION }
};
@ -56,61 +56,16 @@ static GimpActionEntry file_open_actions[] =
void
file_open_actions_setup (GimpActionGroup *group)
{
GSList *list;
gimp_action_group_add_actions (group,
file_open_actions,
G_N_ELEMENTS (file_open_actions));
for (list = group->gimp->load_procs; list; list = g_slist_next (list))
{
PlugInProcDef *file_proc = list->data;
const gchar *locale_domain = NULL;
const gchar *stock_id = NULL;
gchar *help_id;
GimpActionEntry entry;
gboolean is_xcf;
GtkAction *action;
gimp_action_group_add_plug_in_actions (group,
file_open_file_type_actions,
G_N_ELEMENTS (file_open_file_type_actions),
G_CALLBACK (file_dialog_type_cmd_callback));
if (! file_proc->menu_path)
continue;
is_xcf = (strcmp (file_proc->db_info.name, "gimp_xcf_load") == 0);
if (is_xcf)
{
stock_id = GIMP_STOCK_WILBER;
help_id = g_strdup (GIMP_HELP_FILE_OPEN_XCF);
}
else
{
const gchar *progname;
const gchar *help_domain;
progname = plug_in_proc_def_get_progname (file_proc);
locale_domain = plug_ins_locale_domain (group->gimp, progname, NULL);
help_domain = plug_ins_help_domain (group->gimp, progname, NULL);
help_id = plug_in_proc_def_get_help_id (file_proc, help_domain);
}
entry.name = file_proc->db_info.name;
entry.stock_id = stock_id;
entry.label = strstr (file_proc->menu_path, "/") + 1;
entry.tooltip = NULL;
entry.callback = G_CALLBACK (file_type_cmd_callback);
entry.help_id = help_id;
gimp_action_group_add_actions (group, &entry, 1);
g_free (help_id);
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
file_proc->db_info.name);
g_object_set_data (G_OBJECT (action), "file-proc", file_proc);
}
file_dialog_actions_setup (group, group->gimp->load_procs, "gimp_xcf_load");
}
void

View File

@ -27,15 +27,12 @@
#include "actions-types.h"
#include "core/gimp.h"
#include "core/gimpdrawable.h"
#include "plug-in/plug-in-proc.h"
#include "plug-in/plug-ins.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
#include "file-commands.h"
#include "file-dialog-actions.h"
#include "file-dialog-commands.h"
#include "file-save-actions.h"
#include "gimp-intl.h"
@ -44,11 +41,14 @@
static GimpActionEntry file_save_actions[] =
{
{ "file-save-popup", NULL, N_("File Save Menu"), NULL, NULL, NULL,
GIMP_HELP_FILE_SAVE },
GIMP_HELP_FILE_SAVE }
};
static GimpPlugInActionEntry file_save_file_type_actions[] =
{
{ "file-save-by-extension", NULL,
N_("By Extension"), NULL, NULL,
G_CALLBACK (file_type_cmd_callback),
NULL,
GIMP_HELP_FILE_SAVE_BY_EXTENSION }
};
@ -56,61 +56,16 @@ static GimpActionEntry file_save_actions[] =
void
file_save_actions_setup (GimpActionGroup *group)
{
GSList *list;
gimp_action_group_add_actions (group,
file_save_actions,
G_N_ELEMENTS (file_save_actions));
for (list = group->gimp->save_procs; list; list = g_slist_next (list))
{
PlugInProcDef *file_proc = list->data;
const gchar *locale_domain = NULL;
const gchar *stock_id = NULL;
gchar *help_id;
GimpActionEntry entry;
gboolean is_xcf;
GtkAction *action;
gimp_action_group_add_plug_in_actions (group,
file_save_file_type_actions,
G_N_ELEMENTS (file_save_file_type_actions),
G_CALLBACK (file_dialog_type_cmd_callback));
if (! file_proc->menu_path)
continue;
is_xcf = (strcmp (file_proc->db_info.name, "gimp_xcf_save") == 0);
if (is_xcf)
{
stock_id = GIMP_STOCK_WILBER;
help_id = g_strdup (GIMP_HELP_FILE_SAVE_XCF);
}
else
{
const gchar *progname;
const gchar *help_domain;
progname = plug_in_proc_def_get_progname (file_proc);
locale_domain = plug_ins_locale_domain (group->gimp, progname, NULL);
help_domain = plug_ins_help_domain (group->gimp, progname, NULL);
help_id = plug_in_proc_def_get_help_id (file_proc, help_domain);
}
entry.name = file_proc->db_info.name;
entry.stock_id = stock_id;
entry.label = strstr (file_proc->menu_path, "/") + 1;
entry.tooltip = NULL;
entry.callback = G_CALLBACK (file_type_cmd_callback);
entry.help_id = help_id;
gimp_action_group_add_actions (group, &entry, 1);
g_free (help_id);
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
file_proc->db_info.name);
g_object_set_data (G_OBJECT (action), "file-proc", file_proc);
}
file_dialog_actions_setup (group, group->gimp->save_procs, "gimp_xcf_save");
}
void