Ejemplo n.º 1
0
static void
tool_manager_connect_options (GimpContext  *user_context,
                              GimpToolInfo *tool_info)
{
  if (tool_info->context_props)
    {
      GimpCoreConfig      *config       = user_context->gimp->config;
      GimpContextPropMask  global_props = 0;

      /*  FG and BG are always shared between all tools  */
      global_props |= GIMP_CONTEXT_FOREGROUND_MASK;
      global_props |= GIMP_CONTEXT_BACKGROUND_MASK;

      if (config->global_brush)
        global_props |= GIMP_CONTEXT_BRUSH_MASK;
      if (config->global_dynamics)
        global_props |= GIMP_CONTEXT_DYNAMICS_MASK;
      if (config->global_pattern)
        global_props |= GIMP_CONTEXT_PATTERN_MASK;
      if (config->global_palette)
        global_props |= GIMP_CONTEXT_PALETTE_MASK;
      if (config->global_gradient)
        global_props |= GIMP_CONTEXT_GRADIENT_MASK;
      if (config->global_font)
        global_props |= GIMP_CONTEXT_FONT_MASK;

      gimp_context_copy_properties (GIMP_CONTEXT (tool_info->tool_options),
                                    user_context,
                                    tool_info->context_props & ~global_props);
      gimp_context_set_parent (GIMP_CONTEXT (tool_info->tool_options),
                               user_context);
    }
}
Ejemplo n.º 2
0
static void
tool_manager_disconnect_options (GimpToolManager *tool_manager,
                                 GimpContext     *user_context,
                                 GimpToolInfo    *tool_info)
{
  if (tool_info->context_props)
    {
      if (GIMP_IS_PAINT_OPTIONS (tool_info->tool_options))
        {
          /* Storing is unconditional, because the user may turn on
           * brush sharing mid use
           */
          gimp_paint_options_copy_brush_props (GIMP_PAINT_OPTIONS (tool_info->tool_options),
                                               tool_manager->shared_paint_options);

          gimp_paint_options_copy_dynamics_props (GIMP_PAINT_OPTIONS (tool_info->tool_options),
                                                  tool_manager->shared_paint_options);

          gimp_paint_options_copy_gradient_props (GIMP_PAINT_OPTIONS (tool_info->tool_options),
                                                  tool_manager->shared_paint_options);
        }

      gimp_context_set_parent (GIMP_CONTEXT (tool_info->tool_options), NULL);
    }
}
Ejemplo n.º 3
0
GimpContext *
gimp_pdb_context_new (Gimp        *gimp,
                      GimpContext *parent,
                      gboolean     set_parent)
{
  GimpContext *context;

  g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
  g_return_val_if_fail (GIMP_IS_CONTEXT (parent), NULL);

  context = g_object_new (GIMP_TYPE_PDB_CONTEXT,
                          "gimp", gimp,
                          "name", "PDB Context",
                          NULL);

  gimp_config_sync (G_OBJECT (parent), G_OBJECT (context), 0);

  if (set_parent)
    {
      gimp_context_define_properties (context,
                                      GIMP_CONTEXT_ALL_PROPS_MASK, FALSE);
      gimp_context_set_parent (context, parent);
    }

  return context;
}
Ejemplo n.º 4
0
static void
tool_manager_disconnect_options (GimpContext  *user_context,
                                 GimpToolInfo *tool_info)
{
  if (tool_info->context_props)
    {
      gimp_context_set_parent (GIMP_CONTEXT (tool_info->tool_options), NULL);
    }
}
Ejemplo n.º 5
0
void
gimp_devices_restore (Gimp *gimp)
{
  GimpDeviceManager *manager;
  GimpContext       *user_context;
  GimpDeviceInfo    *current_device;
  GList             *list;
  gchar             *filename;
  GError            *error = NULL;

  g_return_if_fail (GIMP_IS_GIMP (gimp));

  manager = gimp_devices_get_manager (gimp);

  g_return_if_fail (GIMP_IS_DEVICE_MANAGER (manager));

  user_context = gimp_get_user_context (gimp);

  for (list = GIMP_LIST (manager)->list;
       list;
       list = g_list_next (list))
    {
      GimpDeviceInfo *device_info = list->data;

      gimp_context_copy_properties (user_context, GIMP_CONTEXT (device_info),
                                    GIMP_DEVICE_INFO_CONTEXT_MASK);

      gimp_device_info_set_default_tool (device_info);
    }

  filename = gimp_personal_rc_file ("devicerc");

  if (gimp->be_verbose)
    g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename));

  if (! gimp_config_deserialize_file (GIMP_CONFIG (manager),
                                      filename,
                                      gimp,
                                      &error))
    {
      if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
        gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);

      g_error_free (error);
      /* don't bail out here */
    }

  g_free (filename);

  current_device = gimp_device_manager_get_current_device (manager);

  gimp_context_copy_properties (GIMP_CONTEXT (current_device), user_context,
                                GIMP_DEVICE_INFO_CONTEXT_MASK);
  gimp_context_set_parent (GIMP_CONTEXT (current_device), user_context);
}
Ejemplo n.º 6
0
GimpContext *
gimp_pdb_context_new (Gimp        *gimp,
                      GimpContext *parent,
                      gboolean     set_parent)
{
  GimpPDBContext *context;
  GList          *list;

  g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
  g_return_val_if_fail (GIMP_IS_CONTEXT (parent), NULL);

  context = g_object_new (GIMP_TYPE_PDB_CONTEXT,
                          "gimp", gimp,
                          "name", "PDB Context",
                          NULL);

  gimp_config_sync (G_OBJECT (parent), G_OBJECT (context), 0);

  if (set_parent)
    {
      gimp_context_define_properties (GIMP_CONTEXT (context),
                                      GIMP_CONTEXT_ALL_PROPS_MASK, FALSE);
      gimp_context_set_parent (GIMP_CONTEXT (context), parent);

      for (list = gimp_get_paint_info_iter (gimp);
           list;
           list = g_list_next (list))
        {
          GimpPaintInfo *info = list->data;

          gimp_container_add (context->paint_options_list,
                              GIMP_OBJECT (info->paint_options));
        }
    }
  else
    {
      for (list = GIMP_LIST (GIMP_PDB_CONTEXT (parent)->paint_options_list)->list;
           list;
           list = g_list_next (list))
        {
          GimpPaintOptions *options = gimp_config_duplicate (list->data);

          gimp_container_add (context->paint_options_list,
                              GIMP_OBJECT (options));
          g_object_unref (options);
        }
    }

  return GIMP_CONTEXT (context);
}
Ejemplo n.º 7
0
static void
tool_manager_connect_options (GimpToolManager *tool_manager,
                              GimpContext     *user_context,
                              GimpToolInfo    *tool_info)
{
  if (tool_info->context_props)
    {
      GimpCoreConfig      *config       = user_context->gimp->config;
      GimpContextPropMask  global_props = 0;

      /*  FG and BG are always shared between all tools  */
      global_props |= GIMP_CONTEXT_PROP_MASK_FOREGROUND;
      global_props |= GIMP_CONTEXT_PROP_MASK_BACKGROUND;

      if (config->global_brush)
        global_props |= GIMP_CONTEXT_PROP_MASK_BRUSH;
      if (config->global_dynamics)
        global_props |= GIMP_CONTEXT_PROP_MASK_DYNAMICS;
      if (config->global_pattern)
        global_props |= GIMP_CONTEXT_PROP_MASK_PATTERN;
      if (config->global_palette)
        global_props |= GIMP_CONTEXT_PROP_MASK_PALETTE;
      if (config->global_gradient)
        global_props |= GIMP_CONTEXT_PROP_MASK_GRADIENT;
      if (config->global_font)
        global_props |= GIMP_CONTEXT_PROP_MASK_FONT;

      gimp_context_copy_properties (GIMP_CONTEXT (tool_info->tool_options),
                                    user_context,
                                    tool_info->context_props & ~global_props);
      gimp_context_set_parent (GIMP_CONTEXT (tool_info->tool_options),
                               user_context);

      if (GIMP_IS_PAINT_OPTIONS (tool_info->tool_options))
        {
          if (config->global_brush)
            gimp_paint_options_copy_brush_props (tool_manager->shared_paint_options,
                                                 GIMP_PAINT_OPTIONS (tool_info->tool_options));

          if (config->global_dynamics)
            gimp_paint_options_copy_dynamics_props (tool_manager->shared_paint_options,
                                                    GIMP_PAINT_OPTIONS (tool_info->tool_options));

          if (config->global_gradient)
            gimp_paint_options_copy_gradient_props (tool_manager->shared_paint_options,
                                                    GIMP_PAINT_OPTIONS (tool_info->tool_options));
        }
    }
}