app: bring dialog titles and help IDs to GEGL filter dialogs

Add "title" and "help_id" parameters and members/properties to
GimpToolDialog, GimpToolGui, GimpOperationTool. Also make the order of
parameters more consistent.
This commit is contained in:
Michael Natterer 2016-01-17 20:08:25 +01:00
parent 6e109052ca
commit 06a5b2fa3f
10 changed files with 181 additions and 30 deletions

View File

@ -21,6 +21,7 @@
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "actions-types.h"
@ -49,8 +50,10 @@ filters_filter_cmd_callback (GtkAction *action,
operation,
gtk_action_get_name (action),
gtk_action_get_label (action),
gtk_action_get_tooltip (action),
gtk_action_get_icon_name (action),
gtk_action_get_tooltip (action));
g_object_get_qdata (G_OBJECT (action),
GIMP_HELP_ID));
gimp_filter_history_add (action_data_get_gimp (data), procedure);
filters_history_cmd_callback (NULL, procedure, data);

View File

@ -62,6 +62,7 @@ static gchar * gimp_gegl_procedure_get_description (GimpViewable *viewabl
static const gchar * gimp_gegl_procedure_get_label (GimpProcedure *procedure);
static const gchar * gimp_gegl_procedure_get_menu_label (GimpProcedure *procedure);
static const gchar * gimp_gegl_procedure_get_help_id (GimpProcedure *procedure);
static gboolean gimp_gegl_procedure_get_sensitive (GimpProcedure *procedure,
GimpObject *object);
static GimpValueArray * gimp_gegl_procedure_execute (GimpProcedure *procedure,
@ -101,6 +102,7 @@ gimp_gegl_procedure_class_init (GimpGeglProcedureClass *klass)
proc_class->get_label = gimp_gegl_procedure_get_label;
proc_class->get_menu_label = gimp_gegl_procedure_get_menu_label;
proc_class->get_help_id = gimp_gegl_procedure_get_help_id;
proc_class->get_sensitive = gimp_gegl_procedure_get_sensitive;
proc_class->execute = gimp_gegl_procedure_execute;
proc_class->execute_async = gimp_gegl_procedure_execute_async;
@ -118,6 +120,7 @@ gimp_gegl_procedure_finalize (GObject *object)
g_free (proc->menu_label);
g_free (proc->label);
g_free (proc->help_id);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@ -184,6 +187,14 @@ gimp_gegl_procedure_get_menu_label (GimpProcedure *procedure)
return GIMP_PROCEDURE_CLASS (parent_class)->get_menu_label (procedure);
}
static const gchar *
gimp_gegl_procedure_get_help_id (GimpProcedure *procedure)
{
GimpGeglProcedure *proc = GIMP_GEGL_PROCEDURE (procedure);
return proc->help_id;
}
static gboolean
gimp_gegl_procedure_get_sensitive (GimpProcedure *procedure,
GimpObject *object)
@ -214,12 +225,12 @@ gimp_gegl_procedure_get_sensitive (GimpProcedure *procedure,
}
static GimpValueArray *
gimp_gegl_procedure_execute (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
GimpValueArray *args,
GError **error)
gimp_gegl_procedure_execute (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
GimpValueArray *args,
GError **error)
{
return GIMP_PROCEDURE_CLASS (parent_class)->execute (procedure, gimp,
context, progress,
@ -311,7 +322,9 @@ gimp_gegl_procedure_execute_async (GimpProcedure *procedure,
gimp_operation_tool_set_operation (GIMP_OPERATION_TOOL (active_tool),
procedure->original_name,
gimp_procedure_get_label (procedure),
gimp_viewable_get_icon_name (GIMP_VIEWABLE (procedure)));
gimp_procedure_get_label (procedure),
gimp_viewable_get_icon_name (GIMP_VIEWABLE (procedure)),
gimp_procedure_get_help_id (procedure));
tool_manager_initialize_active (gimp, GIMP_DISPLAY (display));
}
@ -325,8 +338,9 @@ gimp_gegl_procedure_new (Gimp *gimp,
const gchar *operation,
const gchar *name,
const gchar *menu_label,
const gchar *tooltip,
const gchar *icon_name,
const gchar *tooltip)
const gchar *help_id)
{
GimpProcedure *procedure;
@ -338,13 +352,14 @@ gimp_gegl_procedure_new (Gimp *gimp,
procedure = g_object_new (GIMP_TYPE_GEGL_PROCEDURE, NULL);
GIMP_GEGL_PROCEDURE (procedure)->menu_label = g_strdup (menu_label);
GIMP_GEGL_PROCEDURE (procedure)->help_id = g_strdup (help_id);
gimp_object_set_name (GIMP_OBJECT (procedure), name);
gimp_viewable_set_icon_name (GIMP_VIEWABLE (procedure), icon_name);
gimp_procedure_set_strings (procedure,
operation,
tooltip,
"help",
tooltip,
"author", "copyright", "date",
NULL);

View File

@ -42,6 +42,7 @@ struct _GimpGeglProcedure
gchar *menu_label;
gchar *label;
gchar *help_id;
};
struct _GimpGeglProcedureClass
@ -56,8 +57,9 @@ GimpProcedure * gimp_gegl_procedure_new (Gimp *gimp,
const gchar *operation,
const gchar *name,
const gchar *menu_label,
const gchar *tooltip,
const gchar *icon_name,
const gchar *tooltip);
const gchar *help_id);
#endif /* __GIMP_GEGL_PROCEDURE_H__ */

View File

@ -56,6 +56,7 @@ static void gimp_tool_dialog_shell_unmap (GimpDisplayShell *shell,
G_DEFINE_TYPE (GimpToolDialog, gimp_tool_dialog, GIMP_TYPE_VIEWABLE_DIALOG)
static void
gimp_tool_dialog_class_init (GimpToolDialogClass *klass)
{
@ -105,28 +106,40 @@ GtkWidget *
gimp_tool_dialog_new (GimpToolInfo *tool_info,
GdkScreen *screen,
gint monitor,
const gchar *desc,
const gchar *title,
const gchar *description,
const gchar *icon_name,
const gchar *help_id,
...)
{
GtkWidget *dialog;
const gchar *icon_name;
gchar *identifier;
va_list args;
GtkWidget *dialog;
gchar *identifier;
va_list args;
g_return_val_if_fail (GIMP_IS_TOOL_INFO (tool_info), NULL);
icon_name = gimp_viewable_get_icon_name (GIMP_VIEWABLE (tool_info));
if (! title)
title = tool_info->blurb;
if (! description)
description = tool_info->help;
if (! help_id)
help_id = tool_info->help_id;
if (! icon_name)
icon_name = gimp_viewable_get_icon_name (GIMP_VIEWABLE (tool_info));
dialog = g_object_new (GIMP_TYPE_TOOL_DIALOG,
"title", tool_info->blurb,
"title", title,
"role", gimp_object_get_name (tool_info),
"help-func", gimp_standard_help_func,
"help-id", tool_info->help_id,
"description", description,
"icon-name", icon_name,
"description", desc ? desc : tool_info->help,
"help-func", gimp_standard_help_func,
"help-id", help_id,
NULL);
va_start (args, desc);
va_start (args, help_id);
gimp_dialog_add_buttons_valist (GIMP_DIALOG (dialog), args);
va_end (args);

View File

@ -45,7 +45,10 @@ GType gimp_tool_dialog_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_tool_dialog_new (GimpToolInfo *tool_info,
GdkScreen *screen,
gint monitor,
const gchar *desc,
const gchar *title,
const gchar *description,
const gchar *icon_name,
const gchar *help_id,
...) G_GNUC_NULL_TERMINATED;
void gimp_tool_dialog_set_shell (GimpToolDialog *tool_dialog,

View File

@ -63,8 +63,10 @@ typedef struct _GimpToolGuiPrivate GimpToolGuiPrivate;
struct _GimpToolGuiPrivate
{
GimpToolInfo *tool_info;
gchar *title;
gchar *description;
gchar *icon_name;
gchar *help_id;
GList *response_entries;
gint default_response;
gboolean focus_on_map;
@ -189,6 +191,12 @@ gimp_tool_gui_finalize (GObject *object)
{
GimpToolGuiPrivate *private = GET_PRIVATE (object);
if (private->title)
{
g_free (private->title);
private->title = NULL;
}
if (private->description)
{
g_free (private->description);
@ -201,6 +209,12 @@ gimp_tool_gui_finalize (GObject *object)
private->icon_name = NULL;
}
if (private->help_id)
{
g_free (private->help_id);
private->help_id = NULL;
}
if (private->response_entries)
{
g_list_free_full (private->response_entries,
@ -245,7 +259,10 @@ gimp_tool_gui_new (GimpToolInfo *tool_info,
private = GET_PRIVATE (gui);
private->tool_info = g_object_ref (tool_info);
private->title = g_strdup (tool_info->blurb);
private->description = g_strdup (description);
private->icon_name = g_strdup (gimp_viewable_get_icon_name (GIMP_VIEWABLE (tool_info)));
private->help_id = g_strdup (tool_info->help_id);
private->overlay = overlay;
va_start (args, overlay);
@ -268,6 +285,28 @@ gimp_tool_gui_new (GimpToolInfo *tool_info,
return gui;
}
void
gimp_tool_gui_set_title (GimpToolGui *gui,
const gchar *title)
{
GimpToolGuiPrivate *private;
g_return_if_fail (GIMP_IS_TOOL_GUI (gui));
private = GET_PRIVATE (gui);
if (title == private->title)
return;
g_free (private->title);
private->title = g_strdup (title);
if (! title)
title = private->tool_info->blurb;
g_object_set (private->dialog, "title", title, NULL);
}
void
gimp_tool_gui_set_description (GimpToolGui *gui,
const gchar *description)
@ -319,6 +358,35 @@ gimp_tool_gui_set_icon_name (GimpToolGui *gui,
g_object_set (private->dialog, "icon-name", icon_name, NULL);
}
void
gimp_tool_gui_set_help_id (GimpToolGui *gui,
const gchar *help_id)
{
GimpToolGuiPrivate *private;
g_return_if_fail (GIMP_IS_TOOL_GUI (gui));
private = GET_PRIVATE (gui);
if (help_id == private->help_id)
return;
g_free (private->help_id);
private->help_id = g_strdup (help_id);
if (! help_id)
help_id = private->tool_info->help_id;
if (private->overlay)
{
/* TODO */
}
else
{
g_object_set (private->dialog, "help-id", help_id, NULL);
}
}
void
gimp_tool_gui_set_shell (GimpToolGui *gui,
GimpDisplayShell *shell)
@ -708,7 +776,10 @@ gimp_tool_gui_create_dialog (GimpToolGui *gui,
{
private->dialog = gimp_tool_dialog_new (private->tool_info,
screen, monitor,
private->title,
private->description,
private->icon_name,
private->help_id,
NULL);
for (list = private->response_entries; list; list = g_list_next (list))

View File

@ -59,10 +59,14 @@ GimpToolGui * gimp_tool_gui_new (GimpToolInfo *tool_info,
gboolean overlay,
...) G_GNUC_NULL_TERMINATED;
void gimp_tool_gui_set_title (GimpToolGui *gui,
const gchar *title);
void gimp_tool_gui_set_description (GimpToolGui *gui,
const gchar *description);
void gimp_tool_gui_set_icon_name (GimpToolGui *gui,
const gchar *icon_name);
void gimp_tool_gui_set_help_id (GimpToolGui *gui,
const gchar *help_id);
void gimp_tool_gui_set_shell (GimpToolGui *gui,
GimpDisplayShell *shell);

View File

@ -461,7 +461,11 @@ gimp_gegl_tool_operation_changed (GtkWidget *widget,
}
gimp_operation_tool_set_operation (GIMP_OPERATION_TOOL (tool),
operation, NULL, NULL);
operation,
_("GEGL Operation"),
NULL,
GIMP_STOCK_GEGL,
GIMP_HELP_TOOL_GEGL);
g_free (operation);
}
}

View File

@ -173,6 +173,12 @@ gimp_operation_tool_finalize (GObject *object)
tool->operation = NULL;
}
if (tool->title)
{
g_free (tool->title);
tool->title = NULL;
}
if (tool->undo_desc)
{
g_free (tool->undo_desc);
@ -185,6 +191,12 @@ gimp_operation_tool_finalize (GObject *object)
tool->icon_name = NULL;
}
if (tool->help_id)
{
g_free (tool->help_id);
tool->help_id = NULL;
}
g_list_free_full (tool->aux_inputs,
(GDestroyNotify) gimp_operation_tool_aux_input_free);
tool->aux_inputs = NULL;
@ -302,13 +314,17 @@ gimp_operation_tool_dialog (GimpImageMapTool *im_tool)
gtk_widget_show (tool->options_gui);
}
if (tool->title)
gimp_tool_gui_set_title (im_tool->gui, tool->title);
if (tool->undo_desc)
gimp_tool_gui_set_description (GIMP_IMAGE_MAP_TOOL (tool)->gui,
tool->undo_desc);
gimp_tool_gui_set_description (im_tool->gui, tool->undo_desc);
if (tool->icon_name)
gimp_tool_gui_set_icon_name (GIMP_IMAGE_MAP_TOOL (tool)->gui,
tool->icon_name);
gimp_tool_gui_set_icon_name (im_tool->gui, tool->icon_name);
if (tool->help_id)
gimp_tool_gui_set_help_id (im_tool->gui, tool->help_id);
}
static void
@ -621,8 +637,10 @@ gimp_operation_tool_aux_input_free (AuxInput *input)
void
gimp_operation_tool_set_operation (GimpOperationTool *tool,
const gchar *operation,
const gchar *title,
const gchar *undo_desc,
const gchar *icon_name)
const gchar *icon_name,
const gchar *help_id)
{
GimpImageMapTool *im_tool;
GtkSizeGroup *size_group = NULL;
@ -636,15 +654,23 @@ gimp_operation_tool_set_operation (GimpOperationTool *tool,
if (tool->operation)
g_free (tool->operation);
if (tool->title)
g_free (tool->title);
if (tool->undo_desc)
g_free (tool->undo_desc);
if (tool->icon_name)
g_free (tool->icon_name);
if (tool->help_id)
g_free (tool->help_id);
tool->operation = g_strdup (operation);
tool->title = g_strdup (title);
tool->undo_desc = g_strdup (undo_desc);
tool->icon_name = g_strdup (icon_name);
tool->help_id = g_strdup (help_id);
g_list_free_full (tool->aux_inputs,
(GDestroyNotify) gimp_operation_tool_aux_input_free);
@ -737,11 +763,17 @@ gimp_operation_tool_set_operation (GimpOperationTool *tool,
if (im_tool->gui)
{
if (title)
gimp_tool_gui_set_title (im_tool->gui, title);
if (undo_desc)
gimp_tool_gui_set_description (im_tool->gui, undo_desc);
if (icon_name)
gimp_tool_gui_set_icon_name (im_tool->gui, icon_name);
if (help_id)
gimp_tool_gui_set_help_id (im_tool->gui, help_id);
}
if (GIMP_TOOL (tool)->drawable)

View File

@ -38,8 +38,10 @@ struct _GimpOperationTool
GimpImageMapTool parent_instance;
gchar *operation;
gchar *title;
gchar *undo_desc;
gchar *icon_name;
gchar *help_id;
GList *aux_inputs;
@ -61,8 +63,10 @@ GType gimp_operation_tool_get_type (void) G_GNUC_CONST;
void gimp_operation_tool_set_operation (GimpOperationTool *tool,
const gchar *operation,
const gchar *title,
const gchar *undo_desc,
const gchar *icon_name);
const gchar *icon_name,
const gchar *help_id);
#endif /* __GIMP_OPERATION_TOOL_H__ */