## EphyCommandManager EphyCommandManager — Performs commands, such as cut/copy/paste |

## Synopsis

                        EphyCommandManager;
                        EphyCommandManagerIface;
    void                ephy_command_manager_do_command     (EphyCommandManager *manager,
                                                             const char *command);
    gboolean            ephy_command_manager_can_do_command (EphyCommandManager *manager,
                                                             const char *command);

## Object Hierarchy

      GInterface
       +----EphyCommandManager

## Signals

      "command-changed"                                : Run First

## Description

An EphyCommandManager is an interface to an EphyEmbed which is used to perform commands, such as cut/copy/paste. To perform any command, use `ephy_command_manager_do_command()`. To test the availability of a command, use `ephy_command_manager_can_do_command()`. The availability of commands depends on the selection and actions previously performed in the EphyEmbed. For instance, `cmd_copy` is only available if text has been selected; `cmd_undo` is only available if the user has a text input focused and has typed or erased some of its text.

Example 1. Copying selected text in an EphyEmbed

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    #include <ephy-embed.h>
    #include <ephy-command-manager.h>
    static void
    copy_selected_text (EphyEmbed *embed)
    {
            EphyCommandManager *manager;
            manager = EPHY_COMMAND_MANAGER (embed);
            g_return_if_fail (EPHY_IS_COMMAND_MANAGER (manager));
            if (!ephy_command_manager_can_do_command (manager, "cmd_copy")) return;
            ephy_command_manager_do_command (manager, "cmd_copy");
    }

The EphyCommandManager interface can perform any command which is defined in Mozilla. However, for purposes of abstraction, only a certain subset of commands should be used:

Available Commands

cmd_copy | Copies selected text
cmd_cut | Cuts selected text.
cmd_paste | Pastes text from the clipboard (for example, into a text entry)
cmd_undo | Undoes the last action (for example, typing text into a text entry
cmd_redo | Redoes previously `undo`ne actions (for example, in a text entry)

## Details

### EphyCommandManager

    typedef struct _EphyCommandManager EphyCommandManager;

### EphyCommandManagerIface

    typedef struct {
    	GTypeInterface base_iface;

    	void		(* do_command)		(EphyCommandManager *manager,
    						 const char *command);
    	gboolean (* can_do_command) (EphyCommandManager *manager,
    						 const char *command);

    	/* Signals */

    	void		(* command_changed) (EphyCommandManager *manager,
    						 char *command);
    } EphyCommandManagerIface;

### ephy_command_manager_do_command ()

    void                ephy_command_manager_do_command     (EphyCommandManager *manager,
                                                             const char *command);

Performs `command`.

`manager` : | an EphyCommandManager
`command` : | the command

### ephy_command_manager_can_do_command ()

    gboolean            ephy_command_manager_can_do_command (EphyCommandManager *manager,
                                                             const char *command);

Returns `TRUE` if `command` can be performed.

`manager` : | an EphyCommandManager
`command` : | the command
Returns : | `TRUE` if `command` can be performed.

## Signal Details

### The `"command-changed"` signal

    void                user_function                      (EphyCommandManager *manager,
                                                            gchar              *command,
                                                            gpointer            user_data)      : Run First

The ::command-changed signal is emitted when `command` has changed from being available to unavailable, or vice-versa. The new availability can be tested with `ephy_command_manager_can_do_command()`.

`manager` : |
`command` : | The command whose avalability has changed
`user_data` : | user data set when the signal handler was connected.