Beispiel #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);
}
Beispiel #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);
    }
}
Beispiel #3
0
static void
plug_in_actions_build_path (GimpActionGroup *group,
                            const gchar     *path_original,
                            const gchar     *path_translated)
{
  GHashTable *path_table;
  gchar      *copy_original;
  gchar      *copy_translated;
  gchar      *p1, *p2;

  path_table = g_object_get_data (G_OBJECT (group), "plug-in-path-table");

  if (! path_table)
    {
      path_table = g_hash_table_new_full (g_str_hash, g_str_equal,
                                          g_free, NULL);

      g_object_set_data_full (G_OBJECT (group), "plug-in-path-table",
                              path_table,
                              (GDestroyNotify) g_hash_table_destroy);
    }

  copy_original   = gimp_strip_uline (path_original);
  copy_translated = g_strdup (path_translated);

  p1 = strrchr (copy_original, '/');
  p2 = strrchr (copy_translated, '/');

  if (p1 && p2 && ! g_hash_table_lookup (path_table, copy_original))
    {
      GtkAction *action;
      gchar     *label;

      label = p2 + 1;

#if 0
      g_print ("adding plug-in submenu '%s' (%s)\n",
               copy_original, label);
#endif

      action = gtk_action_new (copy_original, label, NULL, NULL);
      gtk_action_group_add_action (GTK_ACTION_GROUP (group), action);
      g_object_unref (action);

      g_hash_table_insert (path_table, g_strdup (copy_original), action);

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

      /* recursively call ourselves with the last part of the path removed */
      plug_in_actions_build_path (group, copy_original, copy_translated);
    }

  g_free (copy_original);
  g_free (copy_translated);
}
Beispiel #4
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);
}
Beispiel #5
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);
    }
}