Blame atk/atkaction.c

Packit d0bcc1
/* ATK -  Accessibility Toolkit
Packit d0bcc1
 * Copyright 2001 Sun Microsystems Inc.
Packit d0bcc1
 *
Packit d0bcc1
 * This library is free software; you can redistribute it and/or
Packit d0bcc1
 * modify it under the terms of the GNU Lesser General Public
Packit d0bcc1
 * License as published by the Free Software Foundation; either
Packit d0bcc1
 * version 2 of the License, or (at your option) any later version.
Packit d0bcc1
 *
Packit d0bcc1
 * This library is distributed in the hope that it will be useful,
Packit d0bcc1
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit d0bcc1
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit d0bcc1
 * Lesser General Public License for more details.
Packit d0bcc1
 *
Packit d0bcc1
 * You should have received a copy of the GNU Lesser General Public
Packit d0bcc1
 * License along with this library; if not, write to the
Packit d0bcc1
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Packit d0bcc1
 * Boston, MA 02111-1307, USA.
Packit d0bcc1
 */
Packit d0bcc1
Packit d0bcc1
#include "config.h"
Packit d0bcc1
Packit d0bcc1
#include "atkaction.h"
Packit d0bcc1
Packit d0bcc1
/**
Packit d0bcc1
 * SECTION:atkaction
Packit d0bcc1
 * @Short_description: The ATK interface provided by UI components
Packit d0bcc1
 * which the user can activate/interact with.
Packit d0bcc1
 * @Title:AtkAction
Packit d0bcc1
 *
Packit d0bcc1
 * #AtkAction should be implemented by instances of #AtkObject classes
Packit d0bcc1
 * with which the user can interact directly, i.e. buttons,
Packit d0bcc1
 * checkboxes, scrollbars, e.g. components which are not "passive"
Packit d0bcc1
 * providers of UI information.
Packit d0bcc1
 *
Packit d0bcc1
 * Exceptions: when the user interaction is already covered by another
Packit d0bcc1
 * appropriate interface such as #AtkEditableText (insert/delete text,
Packit d0bcc1
 * etc.) or #AtkValue (set value) then these actions should not be
Packit d0bcc1
 * exposed by #AtkAction as well.
Packit d0bcc1
 *
Packit d0bcc1
 * Though most UI interactions on components should be invocable via
Packit d0bcc1
 * keyboard as well as mouse, there will generally be a close mapping
Packit d0bcc1
 * between "mouse actions" that are possible on a component and the
Packit d0bcc1
 * AtkActions.  Where mouse and keyboard actions are redundant in
Packit d0bcc1
 * effect, #AtkAction should expose only one action rather than
Packit d0bcc1
 * exposing redundant actions if possible.  By convention we have been
Packit d0bcc1
 * using "mouse centric" terminology for #AtkAction names.
Packit d0bcc1
 *
Packit d0bcc1
 */
Packit d0bcc1
Packit d0bcc1
GType
Packit d0bcc1
atk_action_get_type (void)
Packit d0bcc1
{
Packit d0bcc1
  static GType type = 0;
Packit d0bcc1
Packit d0bcc1
  if (!type) {
Packit d0bcc1
    GTypeInfo tinfo =
Packit d0bcc1
    {
Packit d0bcc1
      sizeof (AtkActionIface),
Packit d0bcc1
      (GBaseInitFunc) NULL,
Packit d0bcc1
      (GBaseFinalizeFunc) NULL,
Packit d0bcc1
Packit d0bcc1
    };
Packit d0bcc1
Packit d0bcc1
    type = g_type_register_static (G_TYPE_INTERFACE, "AtkAction", &tinfo, 0);
Packit d0bcc1
  }
Packit d0bcc1
Packit d0bcc1
  return type;
Packit d0bcc1
}
Packit d0bcc1
Packit d0bcc1
/**
Packit d0bcc1
 * atk_action_do_action:
Packit d0bcc1
 * @action: a #GObject instance that implements AtkActionIface
Packit d0bcc1
 * @i: the action index corresponding to the action to be performed 
Packit d0bcc1
 *
Packit d0bcc1
 * Perform the specified action on the object.
Packit d0bcc1
 *
Packit d0bcc1
 * Returns: %TRUE if success, %FALSE otherwise
Packit d0bcc1
 *
Packit d0bcc1
 **/
Packit d0bcc1
gboolean
Packit d0bcc1
atk_action_do_action (AtkAction *obj,
Packit d0bcc1
                      gint      i)
Packit d0bcc1
{
Packit d0bcc1
  AtkActionIface *iface;
Packit d0bcc1
Packit d0bcc1
  g_return_val_if_fail (ATK_IS_ACTION (obj), FALSE);
Packit d0bcc1
Packit d0bcc1
  iface = ATK_ACTION_GET_IFACE (obj);
Packit d0bcc1
Packit d0bcc1
  if (iface->do_action)
Packit d0bcc1
    return (iface->do_action) (obj, i);
Packit d0bcc1
  else
Packit d0bcc1
    return FALSE;
Packit d0bcc1
}
Packit d0bcc1
Packit d0bcc1
/**
Packit d0bcc1
 * atk_action_get_n_actions:
Packit d0bcc1
 * @action: a #GObject instance that implements AtkActionIface
Packit d0bcc1
 * 
Packit d0bcc1
 * Gets the number of accessible actions available on the object.
Packit d0bcc1
 * If there are more than one, the first one is considered the
Packit d0bcc1
 * "default" action of the object.
Packit d0bcc1
 *
Packit d0bcc1
 * Returns: a the number of actions, or 0 if @action does not
Packit d0bcc1
 * implement this interface.
Packit d0bcc1
 **/
Packit d0bcc1
gint
Packit d0bcc1
atk_action_get_n_actions  (AtkAction *obj)
Packit d0bcc1
{
Packit d0bcc1
  AtkActionIface *iface;
Packit d0bcc1
Packit d0bcc1
  g_return_val_if_fail (ATK_IS_ACTION (obj), 0);
Packit d0bcc1
Packit d0bcc1
  iface = ATK_ACTION_GET_IFACE (obj);
Packit d0bcc1
Packit d0bcc1
  if (iface->get_n_actions)
Packit d0bcc1
    return (iface->get_n_actions) (obj);
Packit d0bcc1
  else
Packit d0bcc1
    return 0;
Packit d0bcc1
}
Packit d0bcc1
Packit d0bcc1
/**
Packit d0bcc1
 * atk_action_get_description:
Packit d0bcc1
 * @action: a #GObject instance that implements AtkActionIface
Packit d0bcc1
 * @i: the action index corresponding to the action to be performed 
Packit d0bcc1
 *
Packit d0bcc1
 * Returns a description of the specified action of the object.
Packit d0bcc1
 *
Packit d0bcc1
 * Returns: (nullable): a description string, or %NULL if @action does
Packit d0bcc1
 * not implement this interface.
Packit d0bcc1
 **/
Packit d0bcc1
const gchar*
Packit d0bcc1
atk_action_get_description (AtkAction *obj,
Packit d0bcc1
                            gint      i)
Packit d0bcc1
{
Packit d0bcc1
  AtkActionIface *iface;
Packit d0bcc1
Packit d0bcc1
  g_return_val_if_fail (ATK_IS_ACTION (obj), NULL);
Packit d0bcc1
Packit d0bcc1
  iface = ATK_ACTION_GET_IFACE (obj);
Packit d0bcc1
Packit d0bcc1
  if (iface->get_description)
Packit d0bcc1
    return (iface->get_description) (obj, i);
Packit d0bcc1
  else
Packit d0bcc1
    return NULL;
Packit d0bcc1
}
Packit d0bcc1
Packit d0bcc1
/**
Packit d0bcc1
 * atk_action_get_name:
Packit d0bcc1
 * @action: a #GObject instance that implements AtkActionIface
Packit d0bcc1
 * @i: the action index corresponding to the action to be performed 
Packit d0bcc1
 *
Packit d0bcc1
 * Returns a non-localized string naming the specified action of the 
Packit d0bcc1
 * object. This name is generally not descriptive of the end result 
Packit d0bcc1
 * of the action, but instead names the 'interaction type' which the 
Packit d0bcc1
 * object supports. By convention, the above strings should be used to 
Packit d0bcc1
 * represent the actions which correspond to the common point-and-click 
Packit d0bcc1
 * interaction techniques of the same name: i.e. 
Packit d0bcc1
 * "click", "press", "release", "drag", "drop", "popup", etc.
Packit d0bcc1
 * The "popup" action should be used to pop up a context menu for the 
Packit d0bcc1
 * object, if one exists.
Packit d0bcc1
 *
Packit d0bcc1
 * For technical reasons, some toolkits cannot guarantee that the 
Packit d0bcc1
 * reported action is actually 'bound' to a nontrivial user event;
Packit d0bcc1
 * i.e. the result of some actions via atk_action_do_action() may be
Packit d0bcc1
 * NIL.
Packit d0bcc1
 *
Packit d0bcc1
 * Returns: (nullable): a name string, or %NULL if @action does not
Packit d0bcc1
 * implement this interface.
Packit d0bcc1
 **/
Packit d0bcc1
const gchar*
Packit d0bcc1
atk_action_get_name (AtkAction *obj,
Packit d0bcc1
                     gint      i)
Packit d0bcc1
{
Packit d0bcc1
  AtkActionIface *iface;
Packit d0bcc1
Packit d0bcc1
  g_return_val_if_fail (ATK_IS_ACTION (obj), NULL);
Packit d0bcc1
Packit d0bcc1
  iface = ATK_ACTION_GET_IFACE (obj);
Packit d0bcc1
Packit d0bcc1
  if (iface->get_name)
Packit d0bcc1
    return (iface->get_name) (obj, i);
Packit d0bcc1
  else
Packit d0bcc1
    return NULL;
Packit d0bcc1
}
Packit d0bcc1
Packit d0bcc1
/**
Packit d0bcc1
 * atk_action_get_localized_name:
Packit d0bcc1
 * @action: a #GObject instance that implements AtkActionIface
Packit d0bcc1
 * @i: the action index corresponding to the action to be performed 
Packit d0bcc1
 *
Packit d0bcc1
 * Returns the localized name of the specified action of the object.
Packit d0bcc1
 *
Packit d0bcc1
 * Returns: (nullable): a name string, or %NULL if @action does not
Packit d0bcc1
 * implement this interface.
Packit d0bcc1
 **/
Packit d0bcc1
const gchar*
Packit d0bcc1
atk_action_get_localized_name (AtkAction *obj,
Packit d0bcc1
                               gint      i)
Packit d0bcc1
{
Packit d0bcc1
  AtkActionIface *iface;
Packit d0bcc1
Packit d0bcc1
  g_return_val_if_fail (ATK_IS_ACTION (obj), NULL);
Packit d0bcc1
Packit d0bcc1
  iface = ATK_ACTION_GET_IFACE (obj);
Packit d0bcc1
Packit d0bcc1
  if (iface->get_localized_name)
Packit d0bcc1
    return (iface->get_localized_name) (obj, i);
Packit d0bcc1
  else
Packit d0bcc1
    return NULL;
Packit d0bcc1
}
Packit d0bcc1
Packit d0bcc1
/**
Packit d0bcc1
 * atk_action_get_keybinding:
Packit d0bcc1
 * @action: a #GObject instance that implements AtkActionIface
Packit d0bcc1
 * @i: the action index corresponding to the action to be performed
Packit d0bcc1
 *
Packit d0bcc1
 * Gets the keybinding which can be used to activate this action, if one
Packit d0bcc1
 * exists. The string returned should contain localized, human-readable,
Packit d0bcc1
 * key sequences as they would appear when displayed on screen. It must
Packit d0bcc1
 * be in the format "mnemonic;sequence;shortcut".
Packit d0bcc1
 *
Packit d0bcc1
 * - The mnemonic key activates the object if it is presently enabled onscreen.
Packit d0bcc1
 *   This typically corresponds to the underlined letter within the widget.
Packit d0bcc1
 *   Example: "n" in a traditional "New..." menu item or the "a" in "Apply" for
Packit d0bcc1
 *   a button.
Packit d0bcc1
 * - The sequence is the full list of keys which invoke the action even if the
Packit d0bcc1
 *   relevant element is not currently shown on screen. For instance, for a menu
Packit d0bcc1
 *   item the sequence is the keybindings used to open the parent menus before
Packit d0bcc1
 *   invoking. The sequence string is colon-delimited. Example: "Alt+F:N" in a
Packit d0bcc1
 *   traditional "New..." menu item.
Packit d0bcc1
 * - The shortcut, if it exists, will invoke the same action without showing
Packit d0bcc1
 *   the component or its enclosing menus or dialogs. Example: "Ctrl+N" in a
Packit d0bcc1
 *   traditional "New..." menu item.
Packit d0bcc1
 *
Packit d0bcc1
 * Example: For a traditional "New..." menu item, the expected return value
Packit d0bcc1
 * would be: "N;Alt+F:N;Ctrl+N" for the English locale and "N;Alt+D:N;Strg+N"
Packit d0bcc1
 * for the German locale. If, hypothetically, this menu item lacked a mnemonic,
Packit d0bcc1
 * it would be represented by ";;Ctrl+N" and ";;Strg+N" respectively.
Packit d0bcc1
 *
Packit d0bcc1
 * Returns: (nullable): the keybinding which can be used to activate
Packit d0bcc1
 * this action, or %NULL if there is no keybinding for this action.
Packit d0bcc1
 *
Packit d0bcc1
 **/
Packit d0bcc1
const gchar*
Packit d0bcc1
atk_action_get_keybinding (AtkAction *obj,
Packit d0bcc1
                           gint      i)
Packit d0bcc1
{
Packit d0bcc1
  AtkActionIface *iface;
Packit d0bcc1
Packit d0bcc1
  g_return_val_if_fail (ATK_IS_ACTION (obj), NULL);
Packit d0bcc1
Packit d0bcc1
  iface = ATK_ACTION_GET_IFACE (obj);
Packit d0bcc1
Packit d0bcc1
  if (iface->get_keybinding)
Packit d0bcc1
    return (iface->get_keybinding) (obj, i);
Packit d0bcc1
  else
Packit d0bcc1
    return NULL;
Packit d0bcc1
}
Packit d0bcc1
Packit d0bcc1
/**
Packit d0bcc1
 * atk_action_set_description:
Packit d0bcc1
 * @action: a #GObject instance that implements AtkActionIface
Packit d0bcc1
 * @i: the action index corresponding to the action to be performed 
Packit d0bcc1
 * @desc: the description to be assigned to this action
Packit d0bcc1
 *
Packit d0bcc1
 * Sets a description of the specified action of the object.
Packit d0bcc1
 *
Packit d0bcc1
 * Returns: a gboolean representing if the description was successfully set;
Packit d0bcc1
 **/
Packit d0bcc1
gboolean
Packit d0bcc1
atk_action_set_description (AtkAction   *obj,
Packit d0bcc1
                            gint        i,
Packit d0bcc1
                            const gchar *desc)
Packit d0bcc1
{
Packit d0bcc1
  AtkActionIface *iface;
Packit d0bcc1
Packit d0bcc1
  g_return_val_if_fail (ATK_IS_ACTION (obj), FALSE);
Packit d0bcc1
Packit d0bcc1
  iface = ATK_ACTION_GET_IFACE (obj);
Packit d0bcc1
Packit d0bcc1
  if (iface->set_description)
Packit d0bcc1
    return (iface->set_description) (obj, i, desc);
Packit d0bcc1
  else
Packit d0bcc1
    return FALSE;
Packit d0bcc1
}