Example #1
0
static void
gimp_container_popup_confirm (GimpPopup *popup)
{
  GimpContainerPopup *c_popup = GIMP_CONTAINER_POPUP (popup);
  GimpObject         *object;

  object = gimp_context_get_by_type (c_popup->context,
                                     gimp_container_get_children_type (c_popup->container));
  gimp_context_set_by_type (c_popup->orig_context,
                            gimp_container_get_children_type (c_popup->container),
                            object);

  GIMP_POPUP_CLASS (parent_class)->confirm (popup);
}
static void
context_select_object (GimpActionSelectType  select_type,
                       GimpContext          *context,
                       GimpContainer        *container)
{
  GimpObject *current;

  current = gimp_context_get_by_type (context,
                                      gimp_container_get_children_type (container));

  current = action_select_object (select_type, container, current);

  if (current)
    gimp_context_set_by_type (context,
                              gimp_container_get_children_type (container), current);
}
Example #3
0
static void
gimp_container_popup_real_confirm (GimpContainerPopup *popup)
{
  GtkWidget  *widget = GTK_WIDGET (popup);
  GimpObject *object;

  object = gimp_context_get_by_type (popup->context,
                                     gimp_container_get_children_type (popup->container));
  gimp_context_set_by_type (popup->orig_context,
                            gimp_container_get_children_type (popup->container),
                            object);

  if (gtk_grab_get_current () == widget)
    gtk_grab_remove (widget);

  gtk_widget_destroy (widget);
}
Example #4
0
static void
gimp_filter_stack_constructed (GObject *object)
{
  GimpContainer *container = GIMP_CONTAINER (object);

  G_OBJECT_CLASS (parent_class)->constructed (object);

  g_assert (g_type_is_a (gimp_container_get_children_type (container),
                         GIMP_TYPE_FILTER));
}
Example #5
0
static void
data_delete_dialog_response (GtkWidget        *dialog,
                             gint              response_id,
                             DataDeleteDialog *delete_data)
{
  gtk_widget_destroy (dialog);

  if (response_id == GTK_RESPONSE_OK)
    {
      GimpDataFactory *factory    = delete_data->factory;
      GimpData        *data       = delete_data->data;
      GimpContainer   *container;
      GimpObject      *new_active = NULL;
      GError          *error      = NULL;

      container = gimp_data_factory_get_container (factory);

      if (delete_data->context &&
          GIMP_OBJECT (data) ==
          gimp_context_get_by_type (delete_data->context,
                                    gimp_container_get_children_type (container)))
        {
          new_active = gimp_container_get_neighbor_of (container,
                                                       GIMP_OBJECT (data));
        }

      if (! gimp_data_factory_data_delete (factory, data, TRUE, &error))
        {
          gimp_message (gimp_data_factory_get_gimp (factory),
                        G_OBJECT (delete_data->parent), GIMP_MESSAGE_ERROR,
                        "%s", error->message);
          g_clear_error (&error);
        }

      if (new_active)
        gimp_context_set_by_type (delete_data->context,
                                  gimp_container_get_children_type (container),
                                  new_active);
    }

  g_slice_free (DataDeleteDialog, delete_data);
}
Example #6
0
static void
gimp_filter_stack_constructed (GObject *object)
{
  GimpContainer *container = GIMP_CONTAINER (object);

  G_OBJECT_CLASS (parent_class)->constructed (object);

  g_assert (g_type_is_a (gimp_container_get_children_type (container),
                         GIMP_TYPE_FILTER));

  gimp_container_add_handler (container, "visibility-changed",
                              G_CALLBACK (gimp_filter_stack_filter_visible),
                              container);
}
Example #7
0
static void
gimp_data_editor_set_context (GimpDocked  *docked,
                              GimpContext *context)
{
  GimpDataEditor *editor = GIMP_DATA_EDITOR (docked);

  if (context == editor->context)
    return;

  if (parent_docked_iface->set_context)
    parent_docked_iface->set_context (docked, context);

  if (editor->context)
    {
      g_signal_handlers_disconnect_by_func (editor->context,
                                            gimp_data_editor_data_changed,
                                            editor);

      g_object_unref (editor->context);
    }

  editor->context = context;

  if (editor->context)
    {
      GType     data_type;
      GimpData *data;

      g_object_ref (editor->context);

      data_type = gimp_container_get_children_type (gimp_data_factory_get_container (editor->data_factory));
      data = GIMP_DATA (gimp_context_get_by_type (editor->context, data_type));

      g_signal_connect (editor->context,
                        gimp_context_type_to_signal_name (data_type),
                        G_CALLBACK (gimp_data_editor_data_changed),
                        editor);

      gimp_data_editor_data_changed (editor->context, data, editor);
    }
}
Example #8
0
void
gimp_data_editor_set_data (GimpDataEditor *editor,
                           GimpData       *data)
{
  g_return_if_fail (GIMP_IS_DATA_EDITOR (editor));
  g_return_if_fail (data == NULL || GIMP_IS_DATA (data));
  g_return_if_fail (data == NULL ||
                    g_type_is_a (G_TYPE_FROM_INSTANCE (data),
                                 gimp_container_get_children_type (gimp_data_factory_get_container (editor->data_factory))));

  if (editor->data != data)
    {
      GIMP_DATA_EDITOR_GET_CLASS (editor)->set_data (editor, data);

      g_object_notify (G_OBJECT (editor), "data");

      if (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)))
        gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)),
                                gimp_editor_get_popup_data (GIMP_EDITOR (editor)));
    }
}
Example #9
0
static gboolean
gui_pdb_dialog_set (Gimp          *gimp,
                    GimpContainer *container,
                    const gchar   *callback_name,
                    const gchar   *object_name,
                    va_list        args)
{
  GimpPdbDialogClass *klass = NULL;

  if (gimp_container_get_children_type (container) == GIMP_TYPE_BRUSH)
    klass = g_type_class_peek (GIMP_TYPE_BRUSH_SELECT);
  else if (gimp_container_get_children_type (container) == GIMP_TYPE_FONT)
    klass = g_type_class_peek (GIMP_TYPE_FONT_SELECT);
  else if (gimp_container_get_children_type (container) == GIMP_TYPE_GRADIENT)
    klass = g_type_class_peek (GIMP_TYPE_GRADIENT_SELECT);
  else if (gimp_container_get_children_type (container) == GIMP_TYPE_PALETTE)
    klass = g_type_class_peek (GIMP_TYPE_PALETTE_SELECT);
  else if (gimp_container_get_children_type (container) == GIMP_TYPE_PATTERN)
    klass = g_type_class_peek (GIMP_TYPE_PATTERN_SELECT);

  if (klass)
    {
      GimpPdbDialog *dialog;

      dialog = gimp_pdb_dialog_get_by_callback (klass, callback_name);

      if (dialog && dialog->select_type == gimp_container_get_children_type (container))
        {
          GimpObject *object;

          object = gimp_container_get_child_by_name (container, object_name);

          if (object)
            {
              const gchar *prop_name = va_arg (args, const gchar *);

              gimp_context_set_by_type (dialog->context, dialog->select_type,
                                        object);

              if (prop_name)
                g_object_set_valist (G_OBJECT (dialog), prop_name, args);

              gtk_window_present (GTK_WINDOW (dialog));

              return TRUE;
            }
        }
    }
Example #10
0
/**
 * gimp_tagged_container_new:
 * @src_container: container to be filtered.
 *
 * Creates a new #GimpTaggedContainer object which creates filtered
 * data view of #GimpTagged objects. It filters @src_container for
 * objects containing all of the filtering tags. Synchronization with
 * @src_container data is performed automatically.
 *
 * Return value: a new #GimpTaggedContainer object.
 **/
GimpContainer *
gimp_tagged_container_new (GimpContainer *src_container)
{
  GimpTaggedContainer *tagged_container;
  GType                children_type;
  GCompareFunc         sort_func;

  g_return_val_if_fail (GIMP_IS_LIST (src_container), NULL);

  children_type = gimp_container_get_children_type (src_container);
  sort_func     = GIMP_LIST (src_container)->sort_func;

  tagged_container = g_object_new (GIMP_TYPE_TAGGED_CONTAINER,
                                   "sort-func",     sort_func,
                                   "children-type", children_type,
                                   "policy",        GIMP_CONTAINER_POLICY_WEAK,
                                   "unique-names",  FALSE,
                                   "src-container", src_container,
                                   NULL);

  return GIMP_CONTAINER (tagged_container);
}
Example #11
0
void
gimp_data_editor_set_edit_active (GimpDataEditor *editor,
                                  gboolean        edit_active)
{
  g_return_if_fail (GIMP_IS_DATA_EDITOR (editor));

  if (editor->edit_active != edit_active)
    {
      editor->edit_active = edit_active;

      if (editor->edit_active && editor->context)
        {
          GType     data_type;
          GimpData *data;

          data_type = gimp_container_get_children_type (gimp_data_factory_get_container (editor->data_factory));
          data = GIMP_DATA (gimp_context_get_by_type (editor->context,
                                                      data_type));

          gimp_data_editor_set_data (editor, data);
        }
    }
}
Example #12
0
GtkWidget *
gimp_container_popup_new (GimpContainer     *container,
                          GimpContext       *context,
                          GimpViewType       view_type,
                          gint               default_view_size,
                          gint               view_size,
                          gint               view_border_width,
                          GimpDialogFactory *dialog_factory,
                          const gchar       *dialog_identifier,
                          const gchar       *dialog_stock_id,
                          const gchar       *dialog_tooltip)
{
  GimpContainerPopup *popup;

  g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
  g_return_val_if_fail (default_view_size >  0 &&
                        default_view_size <= GIMP_VIEWABLE_MAX_POPUP_SIZE,
                        NULL);
  g_return_val_if_fail (view_size >  0 &&
                        view_size <= GIMP_VIEWABLE_MAX_POPUP_SIZE, NULL);
  g_return_val_if_fail (view_border_width >= 0 &&
                        view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH,
                        NULL);
  g_return_val_if_fail (dialog_factory == NULL ||
                        GIMP_IS_DIALOG_FACTORY (dialog_factory), NULL);
  if (dialog_factory)
    {
      g_return_val_if_fail (dialog_identifier != NULL, NULL);
      g_return_val_if_fail (dialog_stock_id != NULL, NULL);
      g_return_val_if_fail (dialog_tooltip != NULL, NULL);
    }

  popup = g_object_new (GIMP_TYPE_CONTAINER_POPUP,
                        "type", GTK_WINDOW_POPUP,
                        NULL);
  gtk_window_set_resizable (GTK_WINDOW (popup), FALSE);

  popup->container    = container;
  popup->orig_context = context;
  popup->context      = gimp_context_new (context->gimp, "popup", context);

  popup->view_type         = view_type;
  popup->default_view_size = default_view_size;
  popup->view_size         = view_size;
  popup->view_border_width = view_border_width;

  g_signal_connect (popup->context,
                    gimp_context_type_to_signal_name (gimp_container_get_children_type (container)),
                    G_CALLBACK (gimp_container_popup_context_changed),
                    popup);

  if (dialog_factory)
    {
      popup->dialog_factory    = dialog_factory;
      popup->dialog_identifier = g_strdup (dialog_identifier);
      popup->dialog_stock_id   = g_strdup (dialog_stock_id);
      popup->dialog_tooltip    = g_strdup (dialog_tooltip);
    }

  gimp_container_popup_create_view (popup);

  return GTK_WIDGET (popup);
}
Example #13
0
gboolean
gimp_container_editor_construct (GimpContainerEditor *editor,
                                 GimpViewType         view_type,
                                 GimpContainer       *container,
                                 GimpContext         *context,
                                 gint                 view_size,
                                 gint                 view_border_width,
                                 GimpMenuFactory     *menu_factory,
                                 const gchar         *menu_identifier,
                                 const gchar         *ui_identifier)
{
    g_return_val_if_fail (GIMP_IS_CONTAINER_EDITOR (editor), FALSE);
    g_return_val_if_fail (GIMP_IS_CONTAINER (container), FALSE);
    g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
    g_return_val_if_fail (view_size > 0 &&
                          view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, FALSE);
    g_return_val_if_fail (view_border_width >= 0 &&
                          view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH,
                          FALSE);
    g_return_val_if_fail (menu_factory == NULL ||
                          GIMP_IS_MENU_FACTORY (menu_factory), FALSE);

    switch (view_type)
    {
    case GIMP_VIEW_TYPE_GRID:
#if 0
        editor->view =
            GIMP_CONTAINER_VIEW (gimp_container_icon_view_new (container,
                                 context,
                                 view_size,
                                 view_border_width));
#else
        editor->view =
            GIMP_CONTAINER_VIEW (gimp_container_grid_view_new (container,
                                 context,
                                 view_size,
                                 view_border_width));
#endif
        break;

    case GIMP_VIEW_TYPE_LIST:
        editor->view =
            GIMP_CONTAINER_VIEW (gimp_container_tree_view_new (container,
                                 context,
                                 view_size,
                                 view_border_width));
        break;

    default:
        g_warning ("%s: unknown GimpViewType passed", G_STRFUNC);
        return FALSE;
    }

    if (GIMP_IS_LIST (container))
        gimp_container_view_set_reorderable (GIMP_CONTAINER_VIEW (editor->view),
                                             ! GIMP_LIST (container)->sort_func);

    if (menu_factory && menu_identifier && ui_identifier)
        gimp_editor_create_menu (GIMP_EDITOR (editor->view),
                                 menu_factory, menu_identifier, ui_identifier,
                                 editor);

    gtk_box_pack_start (GTK_BOX (editor), GTK_WIDGET (editor->view),
                        TRUE, TRUE, 0);
    gtk_widget_show (GTK_WIDGET (editor->view));

    g_signal_connect_object (editor->view, "select-item",
                             G_CALLBACK (gimp_container_editor_select_item),
                             editor, 0);
    g_signal_connect_object (editor->view, "activate-item",
                             G_CALLBACK (gimp_container_editor_activate_item),
                             editor, 0);
    g_signal_connect_object (editor->view, "context-item",
                             G_CALLBACK (gimp_container_editor_context_item),
                             editor, 0);

    {
        GimpObject *object = gimp_context_get_by_type (context,
                             gimp_container_get_children_type (container));

        gimp_container_editor_select_item (GTK_WIDGET (editor->view),
                                           (GimpViewable *) object, NULL,
                                           editor);
    }

    return TRUE;
}
gboolean
gimp_container_tree_view_real_drop_possible (GimpContainerTreeView   *tree_view,
                                             GimpDndType              src_type,
                                             GimpViewable            *src_viewable,
                                             GimpViewable            *dest_viewable,
                                             GtkTreePath             *drop_path,
                                             GtkTreeViewDropPosition  drop_pos,
                                             GtkTreeViewDropPosition *return_drop_pos,
                                             GdkDragAction           *return_drag_action)
{
  GimpContainerView *view           = GIMP_CONTAINER_VIEW (tree_view);
  GimpContainer     *container      = gimp_container_view_get_container (view);
  GimpContainer     *src_container  = NULL;
  GimpContainer     *dest_container = NULL;
  gint               src_index      = -1;
  gint               dest_index     = -1;

  if (src_viewable)
    {
      GimpViewable *parent = gimp_viewable_get_parent (src_viewable);

      if (parent)
        src_container = gimp_viewable_get_children (parent);
      else if (gimp_container_have (container, GIMP_OBJECT (src_viewable)))
        src_container = container;

      if (src_container)
        src_index = gimp_container_get_child_index (src_container,
                                                    GIMP_OBJECT (src_viewable));
    }

  if (dest_viewable)
    {
      GimpViewable *parent;

      /*  dropping on the lower third of a group item drops into that group  */
      if (drop_pos == GTK_TREE_VIEW_DROP_INTO_OR_AFTER &&
          gimp_viewable_get_children (dest_viewable))
        {
          parent = dest_viewable;
        }
      else
        {
          parent = gimp_viewable_get_parent (dest_viewable);
        }

      if (parent)
        dest_container = gimp_viewable_get_children (parent);
      else if (gimp_container_have (container, GIMP_OBJECT (dest_viewable)))
        dest_container = container;

      if (parent == dest_viewable)
        dest_index = 0;
      else
        dest_index = gimp_container_get_child_index (dest_container,
                                                     GIMP_OBJECT (dest_viewable));
    }

  if (src_viewable && g_type_is_a (G_TYPE_FROM_INSTANCE (src_viewable),
                                   gimp_container_get_children_type (container)))
    {
      if (src_viewable == dest_viewable)
        return FALSE;

      if (src_index == -1 || dest_index == -1)
        return FALSE;

      /*  don't allow dropping a parent node onto one of its descendants
       */
      if (gimp_viewable_is_ancestor (src_viewable, dest_viewable))
        return FALSE;
    }

  if (src_container == dest_container)
    {
      if (drop_pos == GTK_TREE_VIEW_DROP_BEFORE)
        {
          if (dest_index == (src_index + 1))
            return FALSE;
        }
      else if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
        {
          if (dest_index == (src_index - 1))
            return FALSE;
        }
    }

  if (return_drop_pos)
    *return_drop_pos = drop_pos;

  if (return_drag_action)
    {
      if (src_viewable && g_type_is_a (G_TYPE_FROM_INSTANCE (src_viewable),
                                       gimp_container_get_children_type (container)))
        *return_drag_action = GDK_ACTION_MOVE;
      else
        *return_drag_action = GDK_ACTION_COPY;
    }

  return TRUE;
}
Example #15
0
void
plug_in_run_cmd_callback (GtkAction           *action,
                          GimpPlugInProcedure *proc,
                          gpointer             data)
{
  GimpProcedure  *procedure = GIMP_PROCEDURE (proc);
  Gimp           *gimp;
  GimpValueArray *args;
  gint            n_args    = 0;
  GimpDisplay    *display   = NULL;
  return_if_no_gimp (gimp, data);

  args = gimp_procedure_get_arguments (procedure);

  /* initialize the first argument  */
  g_value_set_int (gimp_value_array_index (args, n_args),
                   GIMP_RUN_INTERACTIVE);
  n_args++;

  switch (procedure->proc_type)
    {
    case GIMP_EXTENSION:
      break;

    case GIMP_PLUGIN:
    case GIMP_TEMPORARY:
      if (GIMP_IS_DATA_FACTORY_VIEW (data) ||
          GIMP_IS_FONT_VIEW (data)         ||
          GIMP_IS_BUFFER_VIEW (data))
        {
          GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
          GimpContainer       *container;
          GimpContext         *context;
          GimpObject          *object;

          container = gimp_container_view_get_container (editor->view);
          context   = gimp_container_view_get_context (editor->view);

          object = gimp_context_get_by_type (context,
                                             gimp_container_get_children_type (container));

          n_args = plug_in_collect_data_args (action, object,
                                              procedure->args,
                                              args, n_args);
        }
      else if (GIMP_IS_IMAGE_EDITOR (data))
        {
          GimpImageEditor *editor = GIMP_IMAGE_EDITOR (data);
          GimpImage       *image;

          image = gimp_image_editor_get_image (editor);

          n_args = plug_in_collect_image_args (action, image,
                                               procedure->args,
                                               args, n_args);
        }
      else if (GIMP_IS_ITEM_TREE_VIEW (data))
        {
          GimpItemTreeView *view = GIMP_ITEM_TREE_VIEW (data);
          GimpImage        *image;
          GimpItem         *item;

          image = gimp_item_tree_view_get_image (view);

          if (image)
            item = GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_active_item (image);
          else
            item = NULL;

          n_args = plug_in_collect_item_args (action, image, item,
                                              procedure->args,
                                              args, n_args);
        }
      else
        {
          display = action_data_get_display (data);

          n_args = plug_in_collect_display_args (action,
                                                 display,
                                                 procedure->args,
                                                 args, n_args);
        }
      break;

    case GIMP_INTERNAL:
      g_warning ("Unhandled procedure type.");
      n_args = -1;
      break;
    }

  if (n_args >= 1)
    plug_in_procedure_execute (proc, gimp, display, args, n_args);

  gimp_value_array_unref (args);
}
Example #16
0
static gboolean
gui_pdb_dialog_new (Gimp          *gimp,
                    GimpContext   *context,
                    GimpProgress  *progress,
                    GimpContainer *container,
                    const gchar   *title,
                    const gchar   *callback_name,
                    const gchar   *object_name,
                    va_list        args)
{
  GType        dialog_type = G_TYPE_NONE;
  const gchar *dialog_role = NULL;
  const gchar *help_id     = NULL;

  if (gimp_container_get_children_type (container) == GIMP_TYPE_BRUSH)
    {
      dialog_type = GIMP_TYPE_BRUSH_SELECT;
      dialog_role = "gimp-brush-selection";
      help_id     = GIMP_HELP_BRUSH_DIALOG;
    }
  else if (gimp_container_get_children_type (container) == GIMP_TYPE_FONT)
    {
      dialog_type = GIMP_TYPE_FONT_SELECT;
      dialog_role = "gimp-font-selection";
      help_id     = GIMP_HELP_FONT_DIALOG;
    }
  else if (gimp_container_get_children_type (container) == GIMP_TYPE_GRADIENT)
    {
      dialog_type = GIMP_TYPE_GRADIENT_SELECT;
      dialog_role = "gimp-gradient-selection";
      help_id     = GIMP_HELP_GRADIENT_DIALOG;
    }
  else if (gimp_container_get_children_type (container) == GIMP_TYPE_PALETTE)
    {
      dialog_type = GIMP_TYPE_PALETTE_SELECT;
      dialog_role = "gimp-palette-selection";
      help_id     = GIMP_HELP_PALETTE_DIALOG;
    }
  else if (gimp_container_get_children_type (container) == GIMP_TYPE_PATTERN)
    {
      dialog_type = GIMP_TYPE_PATTERN_SELECT;
      dialog_role = "gimp-pattern-selection";
      help_id     = GIMP_HELP_PATTERN_DIALOG;
    }

  if (dialog_type != G_TYPE_NONE)
    {
      GimpObject *object = NULL;

      if (object_name && strlen (object_name))
        object = gimp_container_get_child_by_name (container, object_name);

      if (! object)
        object = gimp_context_get_by_type (context,
                                           gimp_container_get_children_type (container));

      if (object)
        {
          GParameter *params   = NULL;
          gint        n_params = 0;
          GtkWidget  *dialog;
          GtkWidget  *view;

          params = gimp_parameters_append (dialog_type, params, &n_params,
                                           "title",          title,
                                           "role",           dialog_role,
                                           "help-func",      gimp_standard_help_func,
                                           "help-id",        help_id,
                                           "pdb",            gimp->pdb,
                                           "context",        context,
                                           "select-type",    gimp_container_get_children_type (container),
                                           "initial-object", object,
                                           "callback-name",  callback_name,
                                           "menu-factory",   global_menu_factory,
                                           NULL);

          params = gimp_parameters_append_valist (dialog_type,
                                                  params, &n_params,
                                                  args);

          dialog = g_object_newv (dialog_type, n_params, params);

          gimp_parameters_free (params, n_params);

          view = GIMP_PDB_DIALOG (dialog)->view;
          if (view)
            gimp_docked_set_show_button_bar (GIMP_DOCKED (view), FALSE);

          if (progress)
            {
              guint32 window_id = gimp_progress_get_window_id (progress);

              if (window_id)
                gimp_window_set_transient_for (GTK_WINDOW (dialog), window_id);
            }

          gtk_widget_show (dialog);

          /*  workaround for bug #360106  */
          {
            GSource  *source = g_timeout_source_new (100);
            GClosure *closure;

            closure = g_cclosure_new_object (G_CALLBACK (gui_pdb_dialog_present),
                                             G_OBJECT (dialog));

            g_source_set_closure (source, closure);
            g_source_attach (source, NULL);
            g_source_unref (source);
          }

          return TRUE;
        }
    }

  return FALSE;
}