SwamiguiPaste

SwamiguiPaste

Synopsis

enum                SwamiguiPasteStatus;
enum                SwamiguiPasteDecision;
                    SwamiguiPaste;
SwamiguiPaste *     swamigui_paste_new                  (void);
gboolean            swamigui_paste_process              (SwamiguiPaste *paste);
void                swamigui_paste_set_items            (SwamiguiPaste *paste,
                                                         IpatchItem *dstitem,
                                                         GList *srcitems);
void                swamigui_paste_get_conflict_items   (SwamiguiPaste *paste,
                                                         IpatchItem **src,
                                                         IpatchItem **dest);
void                swamigui_paste_set_conflict_items   (SwamiguiPaste *paste,
                                                         IpatchItem *src,
                                                         IpatchItem *dest);
void                swamigui_paste_push_state           (SwamiguiPaste *paste,
                                                         gpointer state);
gpointer            swamigui_paste_pop_state            (SwamiguiPaste *paste);

Object Hierarchy

  GObject
   +----SwamiguiPaste

Description

Details

enum SwamiguiPasteStatus

typedef enum
{
  SWAMIGUI_PASTE_NORMAL,		/* system normal */
  SWAMIGUI_PASTE_ERROR,		/* an error has occured */
  SWAMIGUI_PASTE_UNHANDLED, /* unhandled paste types */
  SWAMIGUI_PASTE_CONFLICT, /* a conflict occured, choice required */
  SWAMIGUI_PASTE_CANCEL		/* cancel paste operation */
} SwamiguiPasteStatus;

enum SwamiguiPasteDecision

typedef enum
{
  SWAMIGUI_PASTE_NO_DECISION = 0,
  SWAMIGUI_PASTE_SKIP = 1 << 0, /* skip item (keep old conflict item) */
  SWAMIGUI_PASTE_CHANGED = 1 << 1, /* item change (check for conflicts, etc) */
  SWAMIGUI_PASTE_REPLACE = 1 << 2 /* replace conflict item */
} SwamiguiPasteDecision;

SwamiguiPaste

typedef struct _SwamiguiPaste SwamiguiPaste;

swamigui_paste_new ()

SwamiguiPaste *     swamigui_paste_new                  (void);

Create a new paste object.

Returns :

New paste object with a ref count of 1.

swamigui_paste_process ()

gboolean            swamigui_paste_process              (SwamiguiPaste *paste);

Run the paste process. This function uses the IpatchPaste system to handle paste operations. May need to be called multiple times to complete a paste operation if decisions are required (conflict paste items, unhandled types, or a cancel occurs). All paste status and parameters are stored in the paste object. This function also groups all state history actions of the paste operation so it can be retracted if the paste is canceled.

paste :

Swami paste object

Returns :

TRUE if paste finished successfully, FALSE if a decision is required or an error occured.

swamigui_paste_set_items ()

void                swamigui_paste_set_items            (SwamiguiPaste *paste,
                                                         IpatchItem *dstitem,
                                                         GList *srcitems);

A function to set the destination item and source item(s) of a paste operation. This function can only be called once on a paste object.

paste :

Swami paste object

dstitem :

Destination item of paste operation

srcitems :

A list of source IpatchItem objects

swamigui_paste_get_conflict_items ()

void                swamigui_paste_get_conflict_items   (SwamiguiPaste *paste,
                                                         IpatchItem **src,
                                                         IpatchItem **dest);

Get conflict items from a paste object (paste status should be SWAMIGUI_PASTE_CONFLICT or these will be NULL). The returned items' reference counts are incremented and the caller is responsible for unrefing them with g_object_unref when finished using them.

paste :

Swami paste object

src :

Location to store a pointer to the source conflict item (item's refcount is incremented) or NULL

dest :

Location to store a pointer to the conflict destination item (item's refcount is incremented) or NULL

swamigui_paste_set_conflict_items ()

void                swamigui_paste_set_conflict_items   (SwamiguiPaste *paste,
                                                         IpatchItem *src,
                                                         IpatchItem *dest);

Set conflict items in a paste object. This function will cause the paste object's status to be set to SWAMIGUI_PASTE_CONFLICT if src and dest are not NULL, otherwise it will be set to SWAMIGUI_PASTE_NORMAL status and the conflict items will be cleared.

paste :

Swami paste object

src :

Source conflict item or NULL

dest :

Destination conflict item or NULL

swamigui_paste_push_state ()

void                swamigui_paste_push_state           (SwamiguiPaste *paste,
                                                         gpointer state);

This function is used by IpatchItem interface "paste" methods to store variable state data to be able to resume a paste operation (after a decision is made on a conflict, etc). The paste object stores a stack of state data so a chain of functions can be resumed at a later time. The methods are responsible for creating and destroying this state data and the function chain will be resumed even on a cancel operation so this can be accomplished properly.

paste :

Swami paste object

state :

IpatchItem "paste" method defined state data

swamigui_paste_pop_state ()

gpointer            swamigui_paste_pop_state            (SwamiguiPaste *paste);

This function is used by IpatchItem interface "paste" methods to retrieve the next variable state data, stored by swamigui_paste_push_state(), to be able to resume a paste operation. The chain of functions storing state data should call this function in the reverse order in which the states were pushed. The state pointer is removed from the stack after this call.

paste :

Swami paste object

Returns :

Pointer to state data which was on the top of the stack.