Пример #1
0
static void
plug_in_actions_menu_branch_added (GimpPlugInManager *manager,
                                   const gchar       *progname,
                                   const gchar       *menu_path,
                                   const gchar       *menu_label,
                                   GimpActionGroup   *group)
{
    const gchar *locale_domain;
    const gchar *path_translated;
    const gchar *label_translated;
    gchar       *full;
    gchar       *full_translated;

    locale_domain =
        gimp_plug_in_manager_get_locale_domain (group->gimp->plug_in_manager,
                progname, NULL);

    path_translated  = dgettext (locale_domain, menu_path);
    label_translated = dgettext (locale_domain, menu_label);

    full            = g_strconcat (menu_path,       "/", menu_label,       NULL);
    full_translated = g_strconcat (path_translated, "/", label_translated, NULL);

    if (plug_in_actions_check_translation (full, full_translated))
        plug_in_actions_build_path (group, full, full_translated);
    else
        plug_in_actions_build_path (group, full, full);

    g_free (full_translated);
    g_free (full);
}
Пример #2
0
static void
plug_in_actions_add_proc (GimpActionGroup     *group,
                          GimpPlugInProcedure *proc)
{
  GimpProcedureActionEntry  entry;
  const gchar              *locale_domain;
  GList                    *list;

  locale_domain = gimp_plug_in_procedure_get_locale_domain (proc);

  entry.name        = gimp_object_get_name (proc);
  entry.icon_name   = gimp_viewable_get_icon_name (GIMP_VIEWABLE (proc));
  entry.label       = gimp_procedure_get_menu_label (GIMP_PROCEDURE (proc));
  entry.accelerator = NULL;
  entry.tooltip     = gimp_procedure_get_blurb (GIMP_PROCEDURE (proc));
  entry.procedure   = GIMP_PROCEDURE (proc);
  entry.help_id     = gimp_procedure_get_help_id (GIMP_PROCEDURE (proc));

  gimp_action_group_add_procedure_actions (group, &entry, 1,
                                           G_CALLBACK (plug_in_run_cmd_callback));

  for (list = proc->menu_paths; list; list = g_list_next (list))
    {
      const gchar *original   = list->data;
      const gchar *translated = dgettext (locale_domain, original);

      if (plug_in_actions_check_translation (original, translated))
        plug_in_actions_build_path (group, original, translated);
      else
        plug_in_actions_build_path (group, original, original);
    }

  if (proc->image_types_val)
    {
      GimpContext  *context  = gimp_get_user_context (group->gimp);
      GimpImage    *image    = gimp_context_get_image (context);
      GimpDrawable *drawable = NULL;
      gboolean      sensitive;
      const gchar  *tooltip;

      if (image)
        drawable = gimp_image_get_active_drawable (image);

      sensitive = gimp_procedure_get_sensitive (GIMP_PROCEDURE (proc),
                                                GIMP_OBJECT (drawable),
                                                &tooltip);

      gimp_action_group_set_action_sensitive (group,
                                              gimp_object_get_name (proc),
                                              sensitive);

      if (! sensitive && drawable && tooltip)
        gimp_action_group_set_action_tooltip (group,
                                              gimp_object_get_name (proc),
                                              tooltip);
    }
}
Пример #3
0
static void
plug_in_actions_menu_path_added (GimpPlugInProcedure *plug_in_proc,
                                 const gchar         *menu_path,
                                 GimpActionGroup     *group)
{
    const gchar *locale_domain;
    const gchar *path_translated;

#if 0
    g_print ("%s: %s (%s)\n", G_STRFUNC,
             gimp_object_get_name (GIMP_OBJECT (plug_in_proc)), menu_path);
#endif

    locale_domain = gimp_plug_in_procedure_get_locale_domain (plug_in_proc);

    path_translated = dgettext (locale_domain, menu_path);

    if (plug_in_actions_check_translation (menu_path, path_translated))
        plug_in_actions_build_path (group, menu_path, path_translated);
    else
        plug_in_actions_build_path (group, menu_path, menu_path);
}
Пример #4
0
static void
plug_in_actions_add_proc (GimpActionGroup     *group,
                          GimpPlugInProcedure *proc)
{
    GimpPlugInActionEntry  entry;
    const gchar           *locale_domain;
    const gchar           *label;
    gchar                 *path_original    = NULL;
    gchar                 *path_translated  = NULL;

    locale_domain = gimp_plug_in_procedure_get_locale_domain (proc);

    if (proc->menu_label)
    {
        label = dgettext (locale_domain, proc->menu_label);
    }
    else
    {
        gchar *p1, *p2;

        path_original   = proc->menu_paths->data;
        path_translated = dgettext (locale_domain, path_original);

        path_original = g_strdup (path_original);

        if (plug_in_actions_check_translation (path_original, path_translated))
            path_translated = g_strdup (path_translated);
        else
            path_translated = g_strdup (path_original);

        p1 = strrchr (path_original, '/');
        p2 = strrchr (path_translated, '/');

        *p1 = '\0';
        *p2 = '\0';

        label = p2 + 1;
    }

    entry.name        = GIMP_OBJECT (proc)->name;
    entry.stock_id    = gimp_plug_in_procedure_get_stock_id (proc);
    entry.label       = label;
    entry.accelerator = NULL;
    entry.tooltip     = gimp_plug_in_procedure_get_blurb (proc);
    entry.procedure   = proc;
    entry.help_id     = gimp_plug_in_procedure_get_help_id (proc);

#if 0
    g_print ("adding plug-in action '%s' (%s)\n",
             GIMP_OBJECT (proc)->name, label);
#endif

    gimp_action_group_add_plug_in_actions (group, &entry, 1,
                                           G_CALLBACK (plug_in_run_cmd_callback));

    g_free ((gchar *) entry.help_id);

    if (proc->menu_label)
    {
        GList *list;

        for (list = proc->menu_paths; list; list = g_list_next (list))
        {
            const gchar *original   = list->data;
            const gchar *translated = dgettext (locale_domain, original);

            if (plug_in_actions_check_translation (original, translated))
                plug_in_actions_build_path (group, original, translated);
            else
                plug_in_actions_build_path (group, original, original);
        }
    }
    else
    {
        plug_in_actions_build_path (group, path_original, path_translated);

        g_free (path_original);
        g_free (path_translated);
    }
}