Commit 50fabff9 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

added new function gimp_ui_manager_activate_action() as a shortcut for

2006-12-15  Sven Neumann  <sven@gimp.org>

	* app/widgets/gimpuimanager.[ch]: added new function
	gimp_ui_manager_activate_action() as a shortcut for looking up the
	action and activating it.

	* app/actions/dialogs-actions.c
	* app/display/gimpdisplayshell-close.c
	* app/widgets/gimpcolormapeditor.c
	* app/widgets/gimpitemtreeview.c
	* app/widgets/gimppaletteeditor.c
	* app/widgets/gimptoolbox.c
	* app/widgets/gimptooloptionseditor.c: use the new function.

	* app/actions/file-commands.c
	* app/dialogs/file-save-dialog.c: minor code cleanup.
parent 4dfd79a4
2006-12-15 Sven Neumann <sven@gimp.org>
* app/widgets/gimpuimanager.[ch]: added new function
gimp_ui_manager_activate_action() as a shortcut for looking up the
action and activating it.
* app/actions/dialogs-actions.c
* app/display/gimpdisplayshell-close.c
* app/widgets/gimpcolormapeditor.c
* app/widgets/gimpitemtreeview.c
* app/widgets/gimppaletteeditor.c
* app/widgets/gimptoolbox.c
* app/widgets/gimptooloptionseditor.c: use the new function.
* app/actions/file-commands.c
* app/dialogs/file-save-dialog.c: minor code cleanup.
2006-12-14 Michael Natterer <mitch@gimp.org>
* app/actions/context-actions.c
......
......@@ -152,7 +152,7 @@ const GimpStringActionEntry dialogs_dockable_actions[] =
GIMP_HELP_FONT_DIALOG },
{ "dialogs-buffers", GIMP_STOCK_BUFFER,
N_("B_uffers"), "", N_("Buffers"),
N_("B_uffers"), "<control><shift>V", N_("Buffers"),
"gimp-buffer-list|gimp-buffer-grid",
GIMP_HELP_BUFFER_DIALOG },
......
......@@ -246,15 +246,12 @@ file_save_cmd_callback (GtkAction *action,
default:
{
gchar *filename;
filename = file_utils_uri_display_name (uri);
gchar *filename = file_utils_uri_display_name (uri);
gimp_message (image->gimp, G_OBJECT (display),
GIMP_MESSAGE_ERROR,
_("Saving '%s' failed:\n\n%s"),
filename, error->message);
g_free (filename);
g_clear_error (&error);
}
......
......@@ -50,21 +50,21 @@
/* local function prototypes */
static void file_save_dialog_response (GtkWidget *save_dialog,
gint response_id,
Gimp *gimp);
static gboolean file_save_dialog_check_uri (GtkWidget *save_dialog,
Gimp *gimp,
gchar **ret_uri,
gchar **ret_basename,
GimpPlugInProcedure **ret_save_proc);
static gboolean file_save_dialog_use_extension (GtkWidget *save_dialog,
const gchar *uri);
static gboolean file_save_dialog_save_image (GtkWidget *save_dialog,
GimpImage *image,
const gchar *uri,
GimpPlugInProcedure *save_proc,
gboolean save_a_copy);
static void file_save_dialog_response (GtkWidget *save_dialog,
gint response_id,
Gimp *gimp);
static gboolean file_save_dialog_check_uri (GtkWidget *save_dialog,
Gimp *gimp,
gchar **ret_uri,
gchar **ret_basename,
GimpPlugInProcedure **ret_save_proc);
static gboolean file_save_dialog_use_extension (GtkWidget *save_dialog,
const gchar *uri);
static gboolean file_save_dialog_save_image (GtkWidget *save_dialog,
GimpImage *image,
const gchar *uri,
GimpPlugInProcedure *save_proc,
gboolean save_a_copy);
/* public functions */
......@@ -499,18 +499,24 @@ file_save_dialog_save_image (GtkWidget *save_dialog,
g_object_unref (image);
if (status != GIMP_PDB_SUCCESS &&
status != GIMP_PDB_CANCEL)
switch (status)
{
gchar *filename = file_utils_uri_display_name (uri);
gimp_message (image->gimp, G_OBJECT (save_dialog), GIMP_MESSAGE_ERROR,
_("Saving '%s' failed:\n\n%s"), filename, error->message);
g_clear_error (&error);
g_free (filename);
success = FALSE;
case GIMP_PDB_SUCCESS:
case GIMP_PDB_CANCEL:
break;
default:
{
gchar *filename = file_utils_uri_display_name (uri);
gimp_message (image->gimp, G_OBJECT (save_dialog), GIMP_MESSAGE_ERROR,
_("Saving '%s' failed:\n\n%s"), filename, error->message);
g_clear_error (&error);
g_free (filename);
success = FALSE;
}
break;
}
for (list = gimp_action_groups_from_name ("file");
......
......@@ -263,16 +263,8 @@ gimp_display_shell_close_response (GtkWidget *widget,
break;
case RESPONSE_SAVE:
{
GtkAction *action;
action = gimp_ui_manager_find_action (shell->menubar_manager,
"file", "file-save-and-close");
g_return_if_fail (action != NULL);
gtk_action_activate (action);
}
gimp_ui_manager_activate_action (shell->menubar_manager,
"file", "file-save-and-close");
break;
default:
......
......@@ -715,16 +715,9 @@ gimp_colormap_preview_button_press (GtkWidget *widget,
g_signal_emit (editor, editor_signals[SELECTED], 0, bevent->state);
if (bevent->type == GDK_2BUTTON_PRESS)
{
GtkAction *action;
action = gimp_ui_manager_find_action (GIMP_EDITOR (editor)->ui_manager,
"colormap",
"colormap-edit-color");
if (action)
gtk_action_activate (action);
}
gimp_ui_manager_activate_action (GIMP_EDITOR (editor)->ui_manager,
"colormap",
"colormap-edit-color");
return TRUE;
case 2:
......
......@@ -650,14 +650,9 @@ gimp_item_tree_view_activate_item (GimpContainerView *view,
if (item_view_class->activate_action)
{
GtkAction *action;
action = gimp_ui_manager_find_action (GIMP_EDITOR (view)->ui_manager,
item_view_class->action_group,
item_view_class->activate_action);
if (action)
gtk_action_activate (action);
gimp_ui_manager_activate_action (GIMP_EDITOR (view)->ui_manager,
item_view_class->action_group,
item_view_class->activate_action);
}
}
......
......@@ -757,14 +757,9 @@ palette_editor_entry_activated (GimpPaletteView *view,
{
if (GIMP_DATA_EDITOR (editor)->data_editable && entry == editor->color)
{
GtkAction *action;
action = gimp_ui_manager_find_action (GIMP_EDITOR (editor)->ui_manager,
"palette-editor",
"palette-editor-edit-color");
if (action)
gtk_action_activate (action);
gimp_ui_manager_activate_action (GIMP_EDITOR (editor)->ui_manager,
"palette-editor",
"palette-editor-edit-color");
}
}
......
......@@ -302,15 +302,11 @@ static gboolean
gimp_toolbox_delete_event (GtkWidget *widget,
GdkEventAny *event)
{
GtkAction *action;
/* activate the action instead of simply calling gimp_exit(), so the
* quit action's senistivity is taken into account
/* Activate the action instead of simply calling gimp_exit(),
* so that the quit action's sensitivity is taken into account.
*/
action = gimp_ui_manager_find_action (GIMP_IMAGE_DOCK (widget)->ui_manager,
"file", "file-quit");
if (action)
gtk_action_activate (action);
gimp_ui_manager_activate_action (GIMP_IMAGE_DOCK (widget)->ui_manager,
"file", "file-quit");
return TRUE;
}
......
......@@ -324,14 +324,9 @@ gimp_tool_options_editor_save_clicked (GtkWidget *widget,
}
else
{
GtkAction *action;
action = gimp_ui_manager_find_action (GIMP_EDITOR (editor)->ui_manager,
"tool-options",
"tool-options-save-new");
if (action)
gtk_action_activate (action);
gimp_ui_manager_activate_action (GIMP_EDITOR (editor)->ui_manager,
"tool-options",
"tool-options-save-new");
}
}
......
......@@ -498,6 +498,25 @@ gimp_ui_manager_find_action (GimpUIManager *manager,
return action;
}
gboolean
gimp_ui_manager_activate_action (GimpUIManager *manager,
const gchar *group_name,
const gchar *action_name)
{
GtkAction *action;
g_return_val_if_fail (GIMP_IS_UI_MANAGER (manager), FALSE);
g_return_val_if_fail (action_name != NULL, FALSE);
action = gimp_ui_manager_find_action (manager, group_name, action_name);
if (action)
gtk_action_activate (action);
return (action != NULL);
}
void
gimp_ui_manager_ui_register (GimpUIManager *manager,
const gchar *ui_path,
......
......@@ -82,9 +82,12 @@ void gimp_ui_manager_update (GimpUIManager *manager,
GimpActionGroup * gimp_ui_manager_get_action_group (GimpUIManager *manager,
const gchar *name);
GtkAction * gimp_ui_manager_find_action (GimpUIManager *manager,
const gchar *group_name,
const gchar *action_name);
GtkAction * gimp_ui_manager_find_action (GimpUIManager *manager,
const gchar *group_name,
const gchar *action_name);
gboolean gimp_ui_manager_activate_action (GimpUIManager *manager,
const gchar *group_name,
const gchar *action_name);
void gimp_ui_manager_ui_register (GimpUIManager *manager,
const gchar *ui_path,
......
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