static DBusMessage *
impl_setTextContents (DBusConnection * bus, DBusMessage * message,
                      void *user_data)
{
  AtkEditableText *editable = (AtkEditableText *) user_data;
  const char *newContents;
  dbus_bool_t rv;
  DBusError error;
  DBusMessage *reply;

  g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data),
                        droute_not_yet_handled_error (message));
  dbus_error_init (&error);
  if (!dbus_message_get_args
      (message, &error, DBUS_TYPE_STRING, &newContents, DBUS_TYPE_INVALID))
    {
      return droute_invalid_arguments_error (message);
    }
  atk_editable_text_set_text_contents (editable, newContents);
  rv = TRUE;
  // TODO decide if we really need this return value
  reply = dbus_message_new_method_return (message);
  if (reply)
    {
      dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
                                DBUS_TYPE_INVALID);
    }
  return reply;
}
static DBusMessage *
impl_insertText (DBusConnection * bus, DBusMessage * message, void *user_data)
{
  AtkEditableText *editable = (AtkEditableText *) user_data;
  dbus_int32_t position, length;
  char *text;
  dbus_bool_t rv;
  DBusError error;
  DBusMessage *reply;
  gint ip;

  g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data),
                        droute_not_yet_handled_error (message));
  dbus_error_init (&error);
  if (!dbus_message_get_args
      (message, &error, DBUS_TYPE_INT32, &position, DBUS_TYPE_STRING, &text,
       DBUS_TYPE_INT32, &length, DBUS_TYPE_INVALID))
    {
      return droute_invalid_arguments_error (message);
    }
  ip = position;
  atk_editable_text_insert_text (editable, text, length, &ip);
  rv = TRUE;
  // TODO decide if we really need this return value
  reply = dbus_message_new_method_return (message);
  if (reply)
    {
      dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
                                DBUS_TYPE_INVALID);
    }
  return reply;
}
static DBusMessage *
impl_DeleteText (DBusConnection * bus, DBusMessage * message, void *user_data)
{
  AtkEditableText *editable = (AtkEditableText *) user_data;
  dbus_int32_t startPos, endPos;
  DBusError error;
  dbus_bool_t rv;
  DBusMessage *reply;

  g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data),
                        droute_not_yet_handled_error (message));
  dbus_error_init (&error);
  if (!dbus_message_get_args
      (message, &error, DBUS_TYPE_INT32, &startPos, DBUS_TYPE_INT32, &endPos,
       DBUS_TYPE_INVALID))
    {
      return droute_invalid_arguments_error (message);
    }
  atk_editable_text_delete_text (editable, startPos, endPos);
  rv = TRUE;
  // TODO decide if we really need this return value
  reply = dbus_message_new_method_return (message);
  if (reply)
    {
      dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
                                DBUS_TYPE_INVALID);
    }
  return reply;
}
Beispiel #4
0
/**
 * atk_editable_text_paste_text:
 * @text: an #AtkEditableText
 * @position: position to paste
 *
 * Paste text from clipboard to specified @position.
 **/
void 
atk_editable_text_paste_text (AtkEditableText  *text,
                              gint             position)
{
  AtkEditableTextIface *iface;

  g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));

  iface = ATK_EDITABLE_TEXT_GET_IFACE (text);

  if (iface->paste_text)
    (*(iface->paste_text)) (text, position);
}
Beispiel #5
0
/**
 * atk_editable_text_set_text_contents:
 * @text: an #AtkEditableText
 * @string: string to set for text contents of @text
 *
 * Set text contents of @text.
 **/
void 
atk_editable_text_set_text_contents (AtkEditableText  *text,
                                     const gchar      *string)
{
  AtkEditableTextIface *iface;

  g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));

  iface = ATK_EDITABLE_TEXT_GET_IFACE (text);

  if (iface->set_text_contents)
    (*(iface->set_text_contents)) (text, string);
}
Beispiel #6
0
/**
 * atk_editable_text_delete_text:
 * @text: an #AtkEditableText
 * @start_pos: start position
 * @end_pos: end position
 *
 * Delete text @start_pos up to, but not including @end_pos.
 **/
void 
atk_editable_text_delete_text (AtkEditableText  *text,
                               gint             start_pos,
                               gint             end_pos)
{
  AtkEditableTextIface *iface;

  g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));

  iface = ATK_EDITABLE_TEXT_GET_IFACE (text);

  if (iface->delete_text)
    (*(iface->delete_text)) (text, start_pos, end_pos);
}
Beispiel #7
0
/**
 * atk_editable_text_insert_text:
 * @text: an #AtkEditableText
 * @string: the text to insert
 * @length: the length of text to insert, in bytes
 * @position: The caller initializes this to 
 * the position at which to insert the text. After the call it
 * points at the position after the newly inserted text.
 *
 * Insert text at a given position.
 **/
void 
atk_editable_text_insert_text (AtkEditableText  *text,
                               const gchar      *string,
                               gint             length,
                               gint             *position)
{
  AtkEditableTextIface *iface;

  g_return_if_fail (ATK_IS_EDITABLE_TEXT (text));

  iface = ATK_EDITABLE_TEXT_GET_IFACE (text);

  if (iface->insert_text)
    (*(iface->insert_text)) (text, string, length, position);
}
static DBusMessage *
impl_copyText (DBusConnection * bus, DBusMessage * message, void *user_data)
{
  AtkEditableText *editable = (AtkEditableText *) user_data;
  dbus_int32_t startPos, endPos;
  DBusError error;

  g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (user_data),
                        droute_not_yet_handled_error (message));
  dbus_error_init (&error);
  if (!dbus_message_get_args
      (message, &error, DBUS_TYPE_INT32, &startPos, DBUS_TYPE_INT32, &endPos,
       DBUS_TYPE_INVALID))
    {
      return droute_invalid_arguments_error (message);
    }
  atk_editable_text_copy_text (editable, startPos, endPos);
  return dbus_message_new_method_return (message);
}
Beispiel #9
0
static void _set_values (AtkObject *obj) {

  GValue *value_back, val;
  static gint count = 0;
  gdouble double_value;

  value_back = &val;

  if(ATK_IS_VALUE(obj)) {
	/* Spin button also inherits the text interfaces from GailEntry. 
	 * Check when spin button recieves focus.
     */

	if(ATK_IS_TEXT(obj) && ATK_IS_EDITABLE_TEXT(obj)) {
		if(count == 0) {	
			gint x;
			gchar* text;
			count++;
			x = atk_text_get_character_count (ATK_TEXT (obj));
  			text = atk_text_get_text (ATK_TEXT (obj), 0, x);
			g_print("Text : %s\n", text);
			text = "5.7";
			atk_editable_text_set_text_contents(ATK_EDITABLE_TEXT(obj),text);
			g_print("Set text to %s\n",text);
			atk_value_get_current_value(ATK_VALUE(obj), value_back);
			g_return_if_fail (G_VALUE_HOLDS_DOUBLE (value_back));
			g_print("atk_value_get_current_value returns %f\n", 
				g_value_get_double( value_back));
			} 
	} else {
		memset (value_back, 0, sizeof (GValue));
		g_value_init (value_back, G_TYPE_DOUBLE);
		g_value_set_double (value_back, 10.0);	
		if (atk_value_set_current_value (ATK_VALUE (obj), value_back))
		{
 			double_value = g_value_get_double (value_back);
  			g_print("atk_value_set_current_value returns %f\n", 
			double_value);
		}
	}
  }
}
Beispiel #10
0
/**
 *atk_editable_text_set_run_attributes:
 *@text: an #AtkEditableText
 *@attrib_set: an #AtkAttributeSet
 *@start_offset: start of range in which to set attributes
 *@end_offset: end of range in which to set attributes
 *
 *Sets the attributes for a specified range. See the ATK_ATTRIBUTE
 *macros (such as #ATK_ATTRIBUTE_LEFT_MARGIN) for examples of attributes 
 *that can be set. Note that other attributes that do not have corresponding
 *ATK_ATTRIBUTE macros may also be set for certain text widgets.
 *
 *Returns: %TRUE if attributes successfully set for the specified
 *range, otherwise %FALSE
 **/
gboolean
atk_editable_text_set_run_attributes (AtkEditableText *text,
                                      AtkAttributeSet *attrib_set,
			              gint start_offset,
                                      gint end_offset)
{
  AtkEditableTextIface *iface;

  g_return_val_if_fail (ATK_IS_EDITABLE_TEXT (text), FALSE);

  iface = ATK_EDITABLE_TEXT_GET_IFACE (text);

  if (iface->set_run_attributes)
    {
      return (*(iface->set_run_attributes)) (text, attrib_set, start_offset, end_offset);
    }
  else
    {
      return FALSE;
    }
}
Beispiel #11
0
static void
_do_test(AtkObject *obj)
{
   gchar *text;
   int start_offset, end_offset;

   g_assert(ATK_IS_EDITABLE_TEXT(obj));

   text = atk_text_get_text(ATK_TEXT(obj), 0, -1);
   if (!g_strcmp0(text, ENTRY_FIRST))
     {
        g_free(text);

        text = g_strdup(ENTRY_TEXT);
        atk_editable_text_set_text_contents(ATK_EDITABLE_TEXT(obj), text);
        g_free(text);

        start_offset = 0;
        end_offset = -1;
        text = atk_text_get_text(ATK_TEXT(obj), start_offset, end_offset);
        g_assert_cmpstr(text, ==, ENTRY_TEXT);
        g_free(text);

        start_offset = 0;
        end_offset = 7;
        atk_editable_text_delete_text(ATK_EDITABLE_TEXT(obj), start_offset, end_offset);
        text = atk_text_get_text(ATK_TEXT(obj), 0, -1);
        g_assert_cmpstr(text, ==, " lololololo olololo");
        g_free(text);

        atk_editable_text_insert_text(ATK_EDITABLE_TEXT(obj), "Trololo", 7,
                                      &start_offset);
        text = atk_text_get_text(ATK_TEXT(obj), 0, -1);
        g_assert(start_offset == 7);
        g_assert_cmpstr(text, ==, ENTRY_TEXT);
        g_free(text);

        start_offset = 8;
        end_offset = 18;
        atk_editable_text_copy_text(ATK_EDITABLE_TEXT(obj), start_offset, end_offset);
        atk_editable_text_set_text_contents(ATK_EDITABLE_TEXT(obj), "123");
        atk_editable_text_paste_text(ATK_EDITABLE_TEXT(obj), 3);

        start_offset = 0;
        end_offset = -1;
        text = atk_text_get_text(ATK_TEXT(obj), start_offset, end_offset);
        g_assert_cmpstr(text, ==, "123lololololo");
        g_free(text);

        start_offset = 0;
        end_offset = 3;
        atk_editable_text_cut_text(ATK_EDITABLE_TEXT(obj), start_offset, end_offset);
        text = atk_text_get_text(ATK_TEXT(obj), start_offset, end_offset);
        g_assert_cmpstr(text, ==, "lol");
        g_free(text);

        start_offset = 0;
        end_offset = -1;
        atk_editable_text_paste_text(ATK_EDITABLE_TEXT(obj), 3);
        text = atk_text_get_text(ATK_TEXT(obj), start_offset, end_offset);
        g_assert_cmpstr(text, ==, "lol123olololo");
        g_free(text);

        atk_editable_text_cut_text(ATK_EDITABLE_TEXT(obj), 3, 6);
        text = atk_text_get_text(ATK_TEXT(obj), 0, -1);
        g_assert_cmpstr(text, ==, "lololololo");
        g_free(text);
     }
Beispiel #12
0
SpiAccessible *
spi_accessible_construct (GType type, AtkObject *o)
{
    SpiAccessible *retval;
    CORBA_Environment ev;

    CORBA_exception_init (&ev);

    g_assert (o);
    g_assert (g_type_is_a (type, SPI_ACCESSIBLE_TYPE));

    if ((retval = g_hash_table_lookup (get_public_refs (), o)))
      {
        bonobo_object_ref (BONOBO_OBJECT (retval));
	return retval;
      }
    else
      {
        retval = g_object_new (type, NULL);
        spi_base_construct (SPI_BASE (retval), G_OBJECT(o));
      }
    
    g_hash_table_insert (get_public_refs (), o, retval);
    g_signal_connect (G_OBJECT (retval), "destroy",
		      G_CALLBACK (de_register_public_ref),
		      NULL);

    /* aggregate appropriate SPI interfaces based on ATK interfaces */
 
    if (ATK_IS_ACTION (o))
      {
        bonobo_object_add_interface (bonobo_object (retval),
		BONOBO_OBJECT (spi_action_interface_new (o)));
      }

    if (ATK_IS_COMPONENT (o))
      {
        bonobo_object_add_interface (bonobo_object (retval),
				     BONOBO_OBJECT (spi_component_interface_new (o)));
      }

    if (ATK_IS_EDITABLE_TEXT (o))
      {
         bonobo_object_add_interface (bonobo_object (retval),
				      BONOBO_OBJECT(spi_editable_text_interface_new (o)));
      }

    else if (ATK_IS_TEXT (o))
       {
         bonobo_object_add_interface (bonobo_object (retval),
				      BONOBO_OBJECT (spi_text_interface_new (o)));
       }

    if (ATK_IS_HYPERTEXT (o))
      {
        bonobo_object_add_interface (bonobo_object (retval),
				     BONOBO_OBJECT (spi_hypertext_interface_new (o)));
      }

    if (ATK_IS_IMAGE (o))
      {
        bonobo_object_add_interface (bonobo_object (retval),
				     BONOBO_OBJECT (spi_image_interface_new (o)));
      }

    if (ATK_IS_SELECTION (o))
      {
        bonobo_object_add_interface (bonobo_object (retval),
				     BONOBO_OBJECT (spi_selection_interface_new (o)));
      }

    if (ATK_IS_TABLE (o))
      {
        bonobo_object_add_interface (bonobo_object (retval),
				     BONOBO_OBJECT (spi_table_interface_new (o)));
      }

    if (ATK_IS_VALUE (o))
      {
        bonobo_object_add_interface (bonobo_object (retval),
				     BONOBO_OBJECT (spi_value_interface_new (o)));
      }

    if (ATK_IS_STREAMABLE_CONTENT (o))
      {
        bonobo_object_add_interface (bonobo_object (retval),
				     BONOBO_OBJECT (spi_streamable_interface_new (o)));
      }
    if (ATK_IS_DOCUMENT (o)) /* We add collection interface to document */
      {

	   
	 SpiDocument *doc = spi_document_interface_new (o);
	 bonobo_object_add_interface (BONOBO_OBJECT (doc), 
				      BONOBO_OBJECT (spi_collection_interface_new (o)));

	 bonobo_object_add_interface (bonobo_object (retval),
					BONOBO_OBJECT (doc));
      }
    if (ATK_IS_HYPERLINK_IMPL (o))
      {
	  /* !!! the cast below is used instead of the ATK_HYPERLINK macro, since 
	   the object 'o' is not really a hyperlink, but is in fact an AtkHyperlinkImpl.
	   Ouch.  This works since it gets cast back to GObject, but it's nasty and needs
	   to be cleaned up.
	  */
	bonobo_object_add_interface (bonobo_object (retval),
				     BONOBO_OBJECT (spi_hyperlink_new ((AtkHyperlink*)o)));
      }

    return retval;
}