Пример #1
0
void
filters_actions_setup (GimpActionGroup *group)
{
  gint i;

  gimp_action_group_add_string_actions (group, "filters-action",
                                        filters_actions,
                                        G_N_ELEMENTS (filters_actions),
                                        G_CALLBACK (filters_filter_cmd_callback));

  for (i = 0; i < G_N_ELEMENTS (filters_actions); i++)
    {
      const GimpStringActionEntry *entry = &filters_actions[i];
      const gchar                 *description;

      description = gegl_operation_get_key (entry->value, "description");

      if (description)
        gimp_action_group_set_action_tooltip (group, entry->name,
                                              description);
    }
}
Пример #2
0
static void
gimp_gegl_tool_operation_changed (GtkWidget    *widget,
                                  GimpGeglTool *tool)
{
  GtkTreeModel *model;
  GtkTreeIter   iter;
  gchar        *operation;

  if (! gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
    return;

  model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));

  gtk_tree_model_get (model, &iter,
                      COLUMN_NAME, &operation,
                      -1);

  if (operation)
    {
      const gchar *description;

      description = gegl_operation_get_key (operation, "description");

      if (description)
        {
          gtk_label_set_text (GTK_LABEL (tool->description_label), description);
          gtk_widget_show (tool->description_label);
        }
      else
        {
          gtk_widget_hide (tool->description_label);
        }

      gimp_operation_tool_set_operation (GIMP_OPERATION_TOOL (tool),
                                         operation, NULL);
      g_free (operation);
    }
}
Пример #3
0
gint
main (gint argc, gchar **argv)
{
  GList      *operations;
  GList      *iter;
  gboolean first = TRUE;

  gegl_init (&argc, &argv);

  g_object_set (gegl_config (),
                "application-license", "GPL3",
                NULL);


  operations = gegl_operations ();

  g_print ("window.opdb=[\n");

  for (iter=operations;iter;iter = g_list_next (iter))
    {
      GeglOperationClass *klass = iter->data;

      const char *name = gegl_operation_class_get_key (klass, "name");
      const char *categoris = gegl_operation_class_get_key (klass, "categories");

      if (first)
        first = FALSE;
      else
        g_print (",");

      g_print ("{'op':'%s'\n", name);

      if (klass->compat_name)
        g_print (",'compat-op':'%s'\n", klass->compat_name);

      if (klass->opencl_support)
        g_print (",'opencl-support':'true'\n");

      g_print (",'parent':'%s'\n", 
          g_type_name (g_type_parent(G_OBJECT_CLASS_TYPE(klass))));

      {
        char *image = operation_to_path (name);

        if (g_file_test (image, G_FILE_TEST_EXISTS))
          g_print (",'image':'%s'\n", image);
        g_free (image);
      }

      {
        gchar *commandline = g_strdup_printf (
            "sh -c \"(cd " TOP_SRCDIR ";grep -r '\\\"%s\\\"' operations) | grep operations | grep -v '~:' | grep '\\\"name\\\"' | cut -f 1 -d ':'\"",
             name);
        gchar *output = NULL;
        
        if (g_spawn_command_line_sync (commandline, &output, NULL, NULL, NULL))
        {
          if (strlen(output))
            {
              output[strlen(output)-1] = 0;
              g_print (
      ",'source':'https://git.gnome.org/browse/gegl/tree/%s'\n", output);
            }
          g_free (output);
        }

        g_free (commandline);
      }

      if (categoris)
      {
        const gchar *ptr = categoris;
          gboolean first = TRUE;
        g_print (",'categories':[");

        while (ptr && *ptr)
          {
            gchar category[64]="";
            gint i=0;
            while (*ptr && *ptr!=':' && i<63)
              {
                category[i++]=*(ptr++);
                category[i]='\0';
              }
            if (*ptr==':')
              ptr++;
            {
              if (first)
                first = FALSE;
              else
                g_print (",");
              g_print ("'%s'", category);
            }
          }
        g_print ("]\n");
      }

      json_list_properties (G_OBJECT_CLASS_TYPE (klass), name);
      json_list_pads (G_OBJECT_CLASS_TYPE (klass), name);

      {
        guint nkeys;
        gchar **keys = gegl_operation_list_keys (name, &nkeys);

        if (keys)
          {
            for (gint i = 0; keys[i]; i++)
              {
                const gchar *value = gegl_operation_get_key (name, keys[i]);

                if (g_str_equal (keys[i], "categories") ||
                    g_str_equal (keys[i], "cl-source") ||
                    g_str_equal (keys[i], "source") ||
                    g_str_equal (keys[i], "name")
                    )
                  continue;

                g_print (",\"%s\":\"", keys[i]);
                json_escape_string (value);
                g_print ("\"\n");
              }
            g_free (keys);
          }
      }

      g_print (" }\n");
    }
  g_print ("]\n");

  return 0;
}
Пример #4
0
void
filters_actions_setup (GimpActionGroup *group)
{
  GimpProcedureActionEntry *entries;
  gint                      n_entries;
  gint                      i;

  gimp_action_group_add_actions (group, "filters-action",
                                 filters_menu_actions,
                                 G_N_ELEMENTS (filters_menu_actions));

  gimp_action_group_add_string_actions (group, "filters-action",
                                        filters_actions,
                                        G_N_ELEMENTS (filters_actions),
                                        G_CALLBACK (filters_filter_cmd_callback));

  gimp_action_group_add_enum_actions (group, "filters-action",
                                      filters_repeat_actions,
                                      G_N_ELEMENTS (filters_repeat_actions),
                                      G_CALLBACK (filters_repeat_cmd_callback));

  for (i = 0; i < G_N_ELEMENTS (filters_actions); i++)
    {
      const GimpStringActionEntry *entry = &filters_actions[i];
      const gchar                 *description;

      description = gegl_operation_get_key (entry->value, "description");

      if (description)
        gimp_action_group_set_action_tooltip (group, entry->name,
                                              description);
    }

  n_entries = gimp_filter_history_size (group->gimp);

  entries = g_new0 (GimpProcedureActionEntry, n_entries);

  for (i = 0; i < n_entries; i++)
    {
      entries[i].name        = g_strdup_printf ("filter-recent-%02d", i + 1);
      entries[i].icon_name   = NULL;
      entries[i].label       = "";
      entries[i].accelerator = "";
      entries[i].tooltip     = NULL;
      entries[i].procedure   = NULL;
      entries[i].help_id     = GIMP_HELP_FILTER_RESHOW;
    }

  gimp_action_group_add_procedure_actions (group, entries, n_entries,
                                           G_CALLBACK (filters_history_cmd_callback));

  for (i = 0; i < n_entries; i++)
    {
      gimp_action_group_set_action_visible (group, entries[i].name, FALSE);
      g_free ((gchar *) entries[i].name);
    }

  g_free (entries);

  g_signal_connect_object (group->gimp, "filter-history-changed",
                           G_CALLBACK (filters_actions_history_changed),
                           group, 0);

  filters_actions_history_changed (group->gimp, group);
}
Пример #5
0
static gboolean
gimp_image_map_tool_initialize (GimpTool     *tool,
                                GimpDisplay  *display,
                                GError      **error)
{
  GimpImageMapTool *im_tool   = GIMP_IMAGE_MAP_TOOL (tool);
  GimpToolInfo     *tool_info = tool->tool_info;
  GimpImage        *image     = gimp_display_get_image (display);
  GimpDrawable     *drawable  = gimp_image_get_active_drawable (image);
  GimpDisplayShell *shell     = gimp_display_get_shell (display);

  if (! drawable)
    return FALSE;

  if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)))
    {
      g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
			   _("Cannot modify the pixels of layer groups."));
      return FALSE;
    }

  if (gimp_item_is_content_locked (GIMP_ITEM (drawable)))
    {
      g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
			   _("The active layer's pixels are locked."));
      return FALSE;
    }

  if (! gimp_item_is_visible (GIMP_ITEM (drawable)))
    {
      g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
                           _("The active layer is not visible."));
      return FALSE;
    }

  if (im_tool->active_picker)
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (im_tool->active_picker),
                                  FALSE);

  /*  set display so the dialog can be hidden on display destruction  */
  tool->display = display;

  if (im_tool->config)
    gimp_config_reset (GIMP_CONFIG (im_tool->config));

  if (! im_tool->gui)
    {
      GimpImageMapToolClass *klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (im_tool);
      GtkWidget             *vbox;
      GtkWidget             *hbox;
      GtkWidget             *toggle;
      gchar                 *operation_name;

      /*  disabled for at least GIMP 2.8  */
      im_tool->overlay = FALSE;

      im_tool->gui =
        gimp_tool_gui_new (tool_info,
                           im_tool->title,
                           im_tool->description,
                           im_tool->icon_name,
                           im_tool->help_id,
                           gtk_widget_get_screen (GTK_WIDGET (shell)),
                           gimp_widget_get_monitor (GTK_WIDGET (shell)),
                           im_tool->overlay,

                           GIMP_STOCK_RESET, RESPONSE_RESET,
                           GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                           GTK_STOCK_OK,     GTK_RESPONSE_OK,

                           NULL);

      gimp_tool_gui_set_default_response (im_tool->gui, GTK_RESPONSE_OK);

      gimp_tool_gui_set_alternative_button_order (im_tool->gui,
                                                  RESPONSE_RESET,
                                                  GTK_RESPONSE_OK,
                                                  GTK_RESPONSE_CANCEL,
                                                  -1);

      vbox = gimp_tool_gui_get_vbox (im_tool->gui);

      g_signal_connect_object (im_tool->gui, "response",
                               G_CALLBACK (gimp_image_map_tool_response),
                               G_OBJECT (im_tool), 0);

      if (im_tool->config && klass->settings_name)
        {
          GType          type = G_TYPE_FROM_INSTANCE (im_tool->config);
          GimpContainer *settings;
          GFile         *settings_file;
          GFile         *default_folder;
          GtkWidget     *settings_ui;

          settings = gimp_gegl_config_get_container (type);
          if (! gimp_list_get_sort_func (GIMP_LIST (settings)))
            gimp_list_set_sort_func (GIMP_LIST (settings),
                                     (GCompareFunc) gimp_settings_compare);

          settings_file = gimp_tool_info_get_options_file (tool_info,
                                                           ".settings");
          default_folder = gimp_directory_file (klass->settings_name, NULL);

          settings_ui = klass->get_settings_ui (im_tool,
                                                settings,
                                                settings_file,
                                                klass->import_dialog_title,
                                                klass->export_dialog_title,
                                                im_tool->help_id,
                                                default_folder,
                                                &im_tool->settings_box);

          g_object_unref (default_folder);
          g_object_unref (settings_file);

          gtk_box_pack_start (GTK_BOX (vbox), settings_ui, FALSE, FALSE, 0);
          gtk_widget_show (settings_ui);
        }

      /*  The gamma hack toggle  */
      toggle = gtk_check_button_new_with_label ("Gamma hack (temp hack, please ignore)");
      gtk_box_pack_end (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
      gtk_widget_show (toggle);

      g_signal_connect (toggle, "toggled",
                        G_CALLBACK (gamma_hack),
                        im_tool);

      /*  The preview and split view toggles  */
      hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
      gtk_box_pack_end (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
      gtk_widget_show (hbox);

      toggle = gimp_prop_check_button_new (G_OBJECT (tool_info->tool_options),
                                           "preview", NULL);
      gtk_box_pack_start (GTK_BOX (hbox), toggle, TRUE, TRUE, 0);
      gtk_widget_show (toggle);

      toggle = gimp_prop_check_button_new (G_OBJECT (tool_info->tool_options),
                                           "preview-split", NULL);
      gtk_box_pack_start (GTK_BOX (hbox), toggle, FALSE, FALSE, 0);
      gtk_widget_show (toggle);

      g_object_bind_property (G_OBJECT (tool_info->tool_options), "preview",
                              toggle,                             "sensitive",
                              G_BINDING_SYNC_CREATE);

      /*  The area combo  */
      gegl_node_get (im_tool->operation,
                     "operation", &operation_name,
                     NULL);

      im_tool->region_combo =
        gimp_prop_enum_combo_box_new (G_OBJECT (tool_info->tool_options),
                                      "region",
                                      0, 0);
      gtk_box_pack_end (GTK_BOX (vbox), im_tool->region_combo,
                        FALSE, FALSE, 0);

      if (operation_name &&
          gegl_operation_get_key (operation_name, "position-dependent"))
        {
          gtk_widget_show (im_tool->region_combo);
        }

      g_free (operation_name);

      /*  Fill in subclass widgets  */
      gimp_image_map_tool_dialog (im_tool);
    }
  else
    {
      gimp_tool_gui_set_title (im_tool->gui, im_tool->title);
      gimp_tool_gui_set_description (im_tool->gui, im_tool->description);
      gimp_tool_gui_set_icon_name (im_tool->gui, im_tool->icon_name);
      gimp_tool_gui_set_help_id (im_tool->gui, im_tool->help_id);
    }

  gimp_tool_gui_set_shell (im_tool->gui, shell);
  gimp_tool_gui_set_viewable (im_tool->gui, GIMP_VIEWABLE (drawable));

  gimp_tool_gui_show (im_tool->gui);

  im_tool->drawable = drawable;
  gimp_image_map_tool_create_map (im_tool);

  gimp_image_map_tool_preview (im_tool);

  return TRUE;
}
Пример #6
0
void
gimp_image_map_tool_get_operation (GimpImageMapTool *im_tool)
{
  GimpImageMapToolClass *klass;
  GimpToolInfo          *tool_info;
  gchar                 *operation_name;

  g_return_if_fail (GIMP_IS_IMAGE_MAP_TOOL (im_tool));

  klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (im_tool);

  tool_info = GIMP_TOOL (im_tool)->tool_info;

  if (im_tool->image_map)
    {
      gimp_image_map_abort (im_tool->image_map);
      g_object_unref (im_tool->image_map);
      im_tool->image_map = NULL;
    }

  if (im_tool->operation)
    {
      g_object_unref (im_tool->operation);
      im_tool->operation = NULL;
    }

  if (im_tool->config)
    {
      g_signal_handlers_disconnect_by_func (im_tool->config,
                                            gimp_image_map_tool_config_notify,
                                            im_tool);

      g_object_unref (im_tool->config);
      im_tool->config = NULL;
    }

  if (im_tool->default_config)
    {
      g_object_unref (im_tool->default_config);
      im_tool->default_config = NULL;
    }

  if (im_tool->title)
    {
      g_free (im_tool->title);
      im_tool->title = NULL;
    }

  if (im_tool->description)
    {
      g_free (im_tool->description);
      im_tool->description = NULL;
    }

  if (im_tool->undo_desc)
    {
      g_free (im_tool->undo_desc);
      im_tool->undo_desc = NULL;
    }

  if (im_tool->icon_name)
    {
      g_free (im_tool->icon_name);
      im_tool->icon_name = NULL;
    }

  if (im_tool->help_id)
    {
      g_free (im_tool->help_id);
      im_tool->help_id = NULL;
    }

  operation_name = klass->get_operation (im_tool,
                                         &im_tool->title,
                                         &im_tool->description,
                                         &im_tool->undo_desc,
                                         &im_tool->icon_name,
                                         &im_tool->help_id);

  if (! operation_name)
    operation_name = g_strdup ("gegl:nop");

  if (! im_tool->title)
    im_tool->title = g_strdup (tool_info->blurb);

  if (! im_tool->description)
    im_tool->description = g_strdup (im_tool->title);

  if (! im_tool->undo_desc)
    im_tool->undo_desc = g_strdup (tool_info->blurb);

  if (! im_tool->icon_name)
    im_tool->icon_name =
      g_strdup (gimp_viewable_get_icon_name (GIMP_VIEWABLE (tool_info)));

  if (! im_tool->help_id)
    im_tool->help_id = g_strdup (tool_info->help_id);

  im_tool->operation = gegl_node_new_child (NULL,
                                            "operation", operation_name,
                                            NULL);
  im_tool->config = G_OBJECT (gimp_gegl_config_new (operation_name,
                                                    im_tool->icon_name,
                                                    GIMP_TYPE_SETTINGS));

  gimp_gegl_config_sync_node (GIMP_OBJECT (im_tool->config),
                              im_tool->operation);
  gimp_gegl_config_connect_node (GIMP_OBJECT (im_tool->config),
                                 im_tool->operation);

  if (im_tool->gui)
    {
      gimp_tool_gui_set_title       (im_tool->gui, im_tool->title);
      gimp_tool_gui_set_description (im_tool->gui, im_tool->description);
      gimp_tool_gui_set_icon_name   (im_tool->gui, im_tool->icon_name);
      gimp_tool_gui_set_help_id     (im_tool->gui, im_tool->help_id);
    }

  if (gegl_operation_get_key (operation_name, "position-dependent"))
    {
      if (im_tool->gui)
        gtk_widget_show (im_tool->region_combo);
    }
  else
    {
      if (im_tool->gui)
        gtk_widget_hide (im_tool->region_combo);

      g_object_set (GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (im_tool),
                    "region", GIMP_IMAGE_MAP_REGION_SELECTION,
                    NULL);
    }

  g_free (operation_name);

  g_object_set (GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (im_tool),
                "preview-split",    FALSE,
                "preview-position", 0.5,
                NULL);

  if (im_tool->config)
    g_signal_connect_object (im_tool->config, "notify",
                             G_CALLBACK (gimp_image_map_tool_config_notify),
                             G_OBJECT (im_tool), 0);

  if (GIMP_TOOL (im_tool)->drawable)
    gimp_image_map_tool_create_map (im_tool);
}
Пример #7
0
void
gimp_image_map_tool_get_operation (GimpImageMapTool *image_map_tool)
{
  GimpImageMapToolClass *klass;
  gchar                 *operation_name;

  g_return_if_fail (GIMP_IS_IMAGE_MAP_TOOL (image_map_tool));

  klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool);

  if (image_map_tool->image_map)
    {
      gimp_image_map_abort (image_map_tool->image_map);
      g_object_unref (image_map_tool->image_map);
      image_map_tool->image_map = NULL;
    }

  if (image_map_tool->operation)
    {
      g_object_unref (image_map_tool->operation);
      image_map_tool->operation = NULL;
    }

  if (image_map_tool->config)
    {
      g_signal_handlers_disconnect_by_func (image_map_tool->config,
                                            gimp_image_map_tool_config_notify,
                                            image_map_tool);

      g_object_unref (image_map_tool->config);
      image_map_tool->config = NULL;
    }

  if (image_map_tool->undo_desc)
    {
      g_free (image_map_tool->undo_desc);
      image_map_tool->undo_desc = NULL;
    }

  image_map_tool->operation = klass->get_operation (image_map_tool,
                                                    &image_map_tool->config,
                                                    &image_map_tool->undo_desc);

  if (! image_map_tool->undo_desc)
    image_map_tool->undo_desc =
      g_strdup (GIMP_TOOL (image_map_tool)->tool_info->blurb);

  gegl_node_get (image_map_tool->operation,
                 "operation", &operation_name,
                 NULL);

  if (operation_name &&
      gegl_operation_get_key (operation_name, "position-dependent"))
    {
      if (image_map_tool->region_combo)
        gtk_widget_show (image_map_tool->region_combo);
    }
  else
    {
      if (image_map_tool->region_combo)
        gtk_widget_show (image_map_tool->region_combo);

      g_object_set (GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (image_map_tool),
                    "region", GIMP_IMAGE_MAP_REGION_SELECTION,
                    NULL);
    }

  g_free (operation_name);

  if (image_map_tool->config)
    g_signal_connect_object (image_map_tool->config, "notify",
                             G_CALLBACK (gimp_image_map_tool_config_notify),
                             G_OBJECT (image_map_tool), 0);

  if (GIMP_TOOL (image_map_tool)->drawable)
    gimp_image_map_tool_create_map (image_map_tool);
}