Commit 3ccb4bed authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

new function which returns a newly allocated string which is the menu

2004-05-18  Michael Natterer  <mitch@gimp.org>

	* app/plug-in/plug-in-proc.[ch] (plug_in_proc_def_get_label): new
	function which returns a newly allocated string which is the menu
	item's name stripped of mnemonics an ellipses.

	* app/actions/plug-in-actions.c (plug_in_actions_update)
	* app/plug-in/plug-in.c (plug_in_get_undo_desc): use the function
	instead of implementing the same twice slightly different.
parent f66f490a
2004-05-18 Michael Natterer <mitch@gimp.org>
* app/plug-in/plug-in-proc.[ch] (plug_in_proc_def_get_label): new
function which returns a newly allocated string which is the menu
item's name stripped of mnemonics an ellipses.
* app/actions/plug-in-actions.c (plug_in_actions_update)
* app/plug-in/plug-in.c (plug_in_get_undo_desc): use the function
instead of implementing the same twice slightly different.
2004-05-17 Sven Neumann <sven@gimp.org>
* plug-ins/common/CEL.c
......
......@@ -193,33 +193,20 @@ plug_in_actions_update (GimpActionGroup *group,
group->gimp->last_plug_in == &proc_def->db_info)
{
const gchar *progname;
const gchar *path;
gchar *stripped;
gchar *basename;
gchar *ellipses;
const gchar *domain;
gchar *label;
gchar *repeat;
gchar *reshow;
progname = plug_in_proc_def_get_progname (proc_def);
domain = plug_ins_locale_domain (group->gimp, progname, NULL);
path = dgettext (plug_ins_locale_domain (group->gimp,
progname, NULL),
proc_def->menu_paths->data);
label = plug_in_proc_def_get_label (proc_def, domain);
stripped = gimp_strip_uline (path);
basename = g_path_get_basename (stripped);
repeat = g_strdup_printf (_("Re_peat \"%s\""), label);
reshow = g_strdup_printf (_("R_e-show \"%s\""), label);
g_free (stripped);
ellipses = strstr (basename, "...");
if (ellipses && ellipses == (basename + strlen (basename) - 3))
*ellipses = '\0';
repeat = g_strdup_printf (_("Re_peat \"%s\""), basename);
reshow = g_strdup_printf (_("R_e-show \"%s\""), basename);
g_free (basename);
g_free (label);
gimp_action_group_set_action_label (group, "plug-in-repeat",
repeat);
......
......@@ -18,6 +18,8 @@
#include "config.h"
#include <string.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
......@@ -112,6 +114,41 @@ plug_in_proc_def_get_progname (const PlugInProcDef *proc_def)
return NULL;
}
gchar *
plug_in_proc_def_get_label (const PlugInProcDef *proc_def,
const gchar *locale_domain)
{
const gchar *path;
gchar *stripped;
gchar *ellipses;
gchar *label;
g_return_val_if_fail (proc_def != NULL, NULL);
if (proc_def->menu_label)
path = dgettext (locale_domain, proc_def->menu_label);
else if (proc_def->menu_paths)
path = dgettext (locale_domain, proc_def->menu_paths->data);
else
return NULL;
stripped = gimp_strip_uline (path);
if (proc_def->menu_label)
label = g_strdup (stripped);
else
label = g_path_get_basename (stripped);
g_free (stripped);
ellipses = strstr (label, "...");
if (ellipses && ellipses == (label + strlen (label) - 3))
*ellipses = '\0';
return label;
}
gchar *
plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def,
const gchar *help_domain)
......
......@@ -49,6 +49,8 @@ void plug_in_proc_def_free (PlugInProcDef *proc_def)
const ProcRecord * plug_in_proc_def_get_proc (const PlugInProcDef *proc_def);
const gchar * plug_in_proc_def_get_progname (const PlugInProcDef *proc_def);
gchar * plug_in_proc_def_get_label (const PlugInProcDef *proc_def,
const gchar *locale_domain);
gchar * plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def,
const gchar *help_domain);
......
......@@ -890,7 +890,7 @@ gchar *
plug_in_get_undo_desc (PlugIn *plug_in)
{
PlugInProcDef *proc_def;
gchar *undo_desc;
gchar *undo_desc = NULL;
g_return_val_if_fail (plug_in != NULL, NULL);
......@@ -903,39 +903,16 @@ plug_in_get_undo_desc (PlugIn *plug_in)
else
proc_def = NULL;
if (proc_def && (proc_def->menu_label || proc_def->menu_paths))
if (proc_def)
{
const gchar *path;
gchar *stripped;
gchar *ellipses;
if (proc_def->menu_label)
path = dgettext (plug_ins_locale_domain (plug_in->gimp,
plug_in->prog, NULL),
proc_def->menu_label);
else
path = dgettext (plug_ins_locale_domain (plug_in->gimp,
plug_in->prog, NULL),
proc_def->menu_paths->data);
stripped = gimp_strip_uline (path);
if (proc_def->menu_label)
undo_desc = g_strdup (stripped);
else
undo_desc = g_strdup (strrchr (stripped, '/') + 1);
g_free (stripped);
const gchar *domain = plug_ins_locale_domain (plug_in->gimp,
plug_in->prog, NULL);
ellipses = strstr (undo_desc, "...");
if (ellipses && ellipses == (undo_desc + strlen (undo_desc) - 3))
*ellipses = '\0';
}
else
{
undo_desc = g_filename_to_utf8 (plug_in->name, -1, NULL, NULL, NULL);
undo_desc = plug_in_proc_def_get_label (proc_def, domain);
}
if (! undo_desc)
undo_desc = g_filename_to_utf8 (plug_in->name, -1, NULL, NULL, NULL);
return undo_desc;
}
......@@ -18,6 +18,8 @@
#include "config.h"
#include <string.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
......@@ -112,6 +114,41 @@ plug_in_proc_def_get_progname (const PlugInProcDef *proc_def)
return NULL;
}
gchar *
plug_in_proc_def_get_label (const PlugInProcDef *proc_def,
const gchar *locale_domain)
{
const gchar *path;
gchar *stripped;
gchar *ellipses;
gchar *label;
g_return_val_if_fail (proc_def != NULL, NULL);
if (proc_def->menu_label)
path = dgettext (locale_domain, proc_def->menu_label);
else if (proc_def->menu_paths)
path = dgettext (locale_domain, proc_def->menu_paths->data);
else
return NULL;
stripped = gimp_strip_uline (path);
if (proc_def->menu_label)
label = g_strdup (stripped);
else
label = g_path_get_basename (stripped);
g_free (stripped);
ellipses = strstr (label, "...");
if (ellipses && ellipses == (label + strlen (label) - 3))
*ellipses = '\0';
return label;
}
gchar *
plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def,
const gchar *help_domain)
......
......@@ -49,6 +49,8 @@ void plug_in_proc_def_free (PlugInProcDef *proc_def)
const ProcRecord * plug_in_proc_def_get_proc (const PlugInProcDef *proc_def);
const gchar * plug_in_proc_def_get_progname (const PlugInProcDef *proc_def);
gchar * plug_in_proc_def_get_label (const PlugInProcDef *proc_def,
const gchar *locale_domain);
gchar * plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def,
const gchar *help_domain);
......
......@@ -18,6 +18,8 @@
#include "config.h"
#include <string.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
......@@ -112,6 +114,41 @@ plug_in_proc_def_get_progname (const PlugInProcDef *proc_def)
return NULL;
}
gchar *
plug_in_proc_def_get_label (const PlugInProcDef *proc_def,
const gchar *locale_domain)
{
const gchar *path;
gchar *stripped;
gchar *ellipses;
gchar *label;
g_return_val_if_fail (proc_def != NULL, NULL);
if (proc_def->menu_label)
path = dgettext (locale_domain, proc_def->menu_label);
else if (proc_def->menu_paths)
path = dgettext (locale_domain, proc_def->menu_paths->data);
else
return NULL;
stripped = gimp_strip_uline (path);
if (proc_def->menu_label)
label = g_strdup (stripped);
else
label = g_path_get_basename (stripped);
g_free (stripped);
ellipses = strstr (label, "...");
if (ellipses && ellipses == (label + strlen (label) - 3))
*ellipses = '\0';
return label;
}
gchar *
plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def,
const gchar *help_domain)
......
......@@ -49,6 +49,8 @@ void plug_in_proc_def_free (PlugInProcDef *proc_def)
const ProcRecord * plug_in_proc_def_get_proc (const PlugInProcDef *proc_def);
const gchar * plug_in_proc_def_get_progname (const PlugInProcDef *proc_def);
gchar * plug_in_proc_def_get_label (const PlugInProcDef *proc_def,
const gchar *locale_domain);
gchar * plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def,
const gchar *help_domain);
......
......@@ -18,6 +18,8 @@
#include "config.h"
#include <string.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
......@@ -112,6 +114,41 @@ plug_in_proc_def_get_progname (const PlugInProcDef *proc_def)
return NULL;
}
gchar *
plug_in_proc_def_get_label (const PlugInProcDef *proc_def,
const gchar *locale_domain)
{
const gchar *path;
gchar *stripped;
gchar *ellipses;
gchar *label;
g_return_val_if_fail (proc_def != NULL, NULL);
if (proc_def->menu_label)
path = dgettext (locale_domain, proc_def->menu_label);
else if (proc_def->menu_paths)
path = dgettext (locale_domain, proc_def->menu_paths->data);
else
return NULL;
stripped = gimp_strip_uline (path);
if (proc_def->menu_label)
label = g_strdup (stripped);
else
label = g_path_get_basename (stripped);
g_free (stripped);
ellipses = strstr (label, "...");
if (ellipses && ellipses == (label + strlen (label) - 3))
*ellipses = '\0';
return label;
}
gchar *
plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def,
const gchar *help_domain)
......
......@@ -49,6 +49,8 @@ void plug_in_proc_def_free (PlugInProcDef *proc_def)
const ProcRecord * plug_in_proc_def_get_proc (const PlugInProcDef *proc_def);
const gchar * plug_in_proc_def_get_progname (const PlugInProcDef *proc_def);
gchar * plug_in_proc_def_get_label (const PlugInProcDef *proc_def,
const gchar *locale_domain);
gchar * plug_in_proc_def_get_help_id (const PlugInProcDef *proc_def,
const gchar *help_domain);
......
......@@ -890,7 +890,7 @@ gchar *
plug_in_get_undo_desc (PlugIn *plug_in)
{
PlugInProcDef *proc_def;
gchar *undo_desc;
gchar *undo_desc = NULL;
g_return_val_if_fail (plug_in != NULL, NULL);
......@@ -903,39 +903,16 @@ plug_in_get_undo_desc (PlugIn *plug_in)
else
proc_def = NULL;
if (proc_def && (proc_def->menu_label || proc_def->menu_paths))
if (proc_def)
{
const gchar *path;
gchar *stripped;
gchar *ellipses;
if (proc_def->menu_label)
path = dgettext (plug_ins_locale_domain (plug_in->gimp,
plug_in->prog, NULL),
proc_def->menu_label);
else
path = dgettext (plug_ins_locale_domain (plug_in->gimp,
plug_in->prog, NULL),
proc_def->menu_paths->data);
stripped = gimp_strip_uline (path);
if (proc_def->menu_label)
undo_desc = g_strdup (stripped);
else
undo_desc = g_strdup (strrchr (stripped, '/') + 1);
g_free (stripped);
const gchar *domain = plug_ins_locale_domain (plug_in->gimp,
plug_in->prog, NULL);
ellipses = strstr (undo_desc, "...");
if (ellipses && ellipses == (undo_desc + strlen (undo_desc) - 3))
*ellipses = '\0';
}
else
{
undo_desc = g_filename_to_utf8 (plug_in->name, -1, NULL, NULL, NULL);
undo_desc = plug_in_proc_def_get_label (proc_def, domain);
}
if (! undo_desc)
undo_desc = g_filename_to_utf8 (plug_in->name, -1, NULL, NULL, NULL);
return undo_desc;
}
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