<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 
               "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<refentry id="EphyCommandManager">
<refmeta>
<refentrytitle role="top_of_page" id="EphyCommandManager.top_of_page">EphyCommandManager</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>EPIPHANY Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>EphyCommandManager</refname>
<refpurpose>Performs commands, such as cut/copy/paste</refpurpose>
</refnamediv>

<refsynopsisdiv id="EphyCommandManager.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>
                    <link linkend="EphyCommandManager-struct">EphyCommandManager</link>;
                    <link linkend="EphyCommandManagerIface">EphyCommandManagerIface</link>;
<link linkend="void">void</link>                <link linkend="ephy-command-manager-do-command">ephy_command_manager_do_command</link>     (<link linkend="EphyCommandManager">EphyCommandManager</link> *manager,
                                                         const <link linkend="char">char</link> *command);
<link linkend="gboolean">gboolean</link>            <link linkend="ephy-command-manager-can-do-command">ephy_command_manager_can_do_command</link> (<link linkend="EphyCommandManager">EphyCommandManager</link> *manager,
                                                         const <link linkend="char">char</link> *command);
</synopsis>
</refsynopsisdiv>

<refsect1 id="EphyCommandManager.object-hierarchy" role="object_hierarchy">
<title role="object_hierarchy.title">Object Hierarchy</title>
<synopsis>
  <link linkend="GInterface">GInterface</link>
   +----EphyCommandManager
</synopsis>
</refsect1>




<refsect1 id="EphyCommandManager.implementations" role="implementations">
<title role="implementations.title">Known Implementations</title>
<para>
EphyCommandManager is implemented by
 <link linkend="EphyEmbed">EphyEmbed</link>.</para>
</refsect1>


<refsect1 id="EphyCommandManager.signals" role="signal_proto">
<title role="signal_proto.title">Signals</title>
<synopsis>
  &quot;<link linkend="EphyCommandManager-command-changed">command-changed</link>&quot;                                : Run First
</synopsis>
</refsect1>


<refsect1 id="EphyCommandManager.description" role="desc">
<title role="desc.title">Description</title>

<para>
An <link linkend="EphyCommandManager"><type>EphyCommandManager</type></link> is an interface to an <link linkend="EphyEmbed"><type>EphyEmbed</type></link> which is used to perform
commands, such as cut/copy/paste. To perform any command, use
<link linkend="ephy-command-manager-do-command"><function>ephy_command_manager_do_command()</function></link>. To test the availability of a command, use
<link linkend="ephy-command-manager-can-do-command"><function>ephy_command_manager_can_do_command()</function></link>. The availability of commands depends on
the selection and actions previously performed in the <link linkend="EphyEmbed."><type>EphyEmbed.</type></link> For instance,
<link linkend="cmd-copy"><literal>cmd_copy</literal></link> is only available if text has been selected; <link linkend="cmd-undo"><literal>cmd_undo</literal></link> is only
available if the user has a text input focused and has typed or erased some of
its text.
</para>
<para>
<example>
<title>Copying selected text in an <link linkend="EphyEmbed"><type>EphyEmbed</type></link></title>
<programlisting>#<![CDATA[include <ephy-embed.h>]]>
#<![CDATA[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");
}]]>
</programlisting>
</example>
</para>
<para>
The <link linkend="EphyCommandManager"><type>EphyCommandManager</type></link> interface can perform any command which is defined in
Mozilla. However, for purposes of abstraction, only a certain subset of commands
should be used:
</para>
<variablelist><title>Available Commands</title>
<varlistentry><term>cmd_copy</term>
<listitem><para>Copies selected text</para></listitem>
</varlistentry>
<varlistentry><term>cmd_cut</term>
<listitem><para>Cuts selected text.</para></listitem>
</varlistentry>
<varlistentry><term>cmd_paste</term>
<listitem><para>Pastes text from the clipboard (for example, into a text entry)
</para></listitem>
</varlistentry>
<varlistentry><term>cmd_undo</term>
<listitem><para>Undoes the last action (for example, typing text into a text
entry</para></listitem>
</varlistentry>
<varlistentry><term>cmd_redo</term>
<listitem><para>Redoes previously <link linkend="undo"><literal>undo</literal></link><!-- -->ne actions (for example, in a
text entry)</para></listitem>
</varlistentry>
</variablelist>
</refsect1>

<refsect1 id="EphyCommandManager.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="EphyCommandManager-struct" role="struct">
<title>EphyCommandManager</title>
<indexterm zone="EphyCommandManager-struct"><primary>EphyCommandManager</primary></indexterm>
<programlisting>typedef struct _EphyCommandManager EphyCommandManager;</programlisting>
<para>
</para></refsect2>
<refsect2 id="EphyCommandManagerIface" role="struct">
<title>EphyCommandManagerIface</title>
<indexterm zone="EphyCommandManagerIface"><primary>EphyCommandManagerIface</primary></indexterm>
<programlisting>typedef struct {
	GTypeInterface base_iface;

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

	/* Signals */

	void		(* command_changed)&#160;(EphyCommandManager *manager,
						 char *command);
} EphyCommandManagerIface;
</programlisting>
<para>
</para></refsect2>
<refsect2 id="ephy-command-manager-do-command" role="function">
<title>ephy_command_manager_do_command ()</title>
<indexterm zone="ephy-command-manager-do-command"><primary>ephy_command_manager_do_command</primary></indexterm>
<programlisting><link linkend="void">void</link>                ephy_command_manager_do_command     (<link linkend="EphyCommandManager">EphyCommandManager</link> *manager,
                                                         const <link linkend="char">char</link> *command);</programlisting>
<para>
Performs <parameter>command</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>manager</parameter>&#160;:</term>
<listitem><simpara> an <link linkend="EphyCommandManager"><type>EphyCommandManager</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>command</parameter>&#160;:</term>
<listitem><simpara> the command
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="ephy-command-manager-can-do-command" role="function">
<title>ephy_command_manager_can_do_command ()</title>
<indexterm zone="ephy-command-manager-can-do-command"><primary>ephy_command_manager_can_do_command</primary></indexterm>
<programlisting><link linkend="gboolean">gboolean</link>            ephy_command_manager_can_do_command (<link linkend="EphyCommandManager">EphyCommandManager</link> *manager,
                                                         const <link linkend="char">char</link> *command);</programlisting>
<para>
Returns <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if <parameter>command</parameter> can be performed.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>manager</parameter>&#160;:</term>
<listitem><simpara> an <link linkend="EphyCommandManager"><type>EphyCommandManager</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>command</parameter>&#160;:</term>
<listitem><simpara> the command
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if <parameter>command</parameter> can be performed.
</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>

<refsect1 id="EphyCommandManager.signal-details" role="signals">
<title role="signals.title">Signal Details</title>
<refsect2 id="EphyCommandManager-command-changed" role="signal"><title>The <literal>&quot;command-changed&quot;</literal> signal</title>
<indexterm zone="EphyCommandManager-command-changed"><primary>EphyCommandManager::command-changed</primary></indexterm>
<programlisting><link linkend="void">void</link>                user_function                      (<link linkend="EphyCommandManager">EphyCommandManager</link> *manager,
                                                        <link linkend="gchar">gchar</link>              *command,
                                                        <link linkend="gpointer">gpointer</link>            user_data)      : Run First</programlisting>
<para>
The ::command-changed signal is emitted when <parameter>command</parameter> has changed from being
available to unavailable, or vice-versa. The new availability can be tested
with <link linkend="ephy-command-manager-can-do-command"><function>ephy_command_manager_can_do_command()</function></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>manager</parameter>&#160;:</term>
<listitem><simpara>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>command</parameter>&#160;:</term>
<listitem><simpara> The command whose avalability has changed
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>user_data</parameter>&#160;:</term>
<listitem><simpara>user data set when the signal handler was connected.</simpara></listitem></varlistentry>
</variablelist></refsect2>
</refsect1>



</refentry>
