After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 676999 - get_text method moved
get_text method moved
Status: RESOLVED FIXED
Product: vte
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: VTE Maintainers
VTE Maintainers
: 677000 (view as bug list)
Depends on:
Blocks: 690003
 
 
Reported: 2012-05-28 22:50 UTC by Agustin Zubiaga
Modified: 2012-12-10 19:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Move definition of VteCharAttributes up (718 bytes, patch)
2012-11-03 14:16 UTC, Simon Schampijer
none Details | Review
Test case using the proposed workaround (1.27 KB, text/plain)
2012-12-10 19:46 UTC, Gonzalo Odiard
  Details
Path to test the proposed solution (824 bytes, patch)
2012-12-10 19:47 UTC, Gonzalo Odiard
none Details | Review

Description Agustin Zubiaga 2012-05-28 22:50:02 UTC
We are using VTE in a terminal (writed in python) for the sugar environment, git.sugarlabs.org/terminal.
Now we are porting this application to GTK3, and we don't found the get_text method.
Where is?
Comment 1 Behdad Esfahbod 2012-05-28 23:52:04 UTC
*** Bug 677000 has been marked as a duplicate of this bug. ***
Comment 2 Manuel Quiñones 2012-05-29 22:18:33 UTC
As Agustin said, vte_terminal_get_text () of VteTerminal is not available via the Python introspection bindings.
Comment 3 S. Daniel Francis 2012-06-20 22:12:38 UTC
The method is available in the C library:
vte_buffer_get_text(VteBuffer *buffer,
                    VteSelectionFunc is_selected,
                    gpointer user_data,
                    GArray *attributes)
But the method vte_view_get_buffer(VteView *terminal) or vte_terminal_get_buffer isn't available in the Python Bindings.
Comment 4 RafaelOrtiz 2012-06-20 22:45:47 UTC
Also is this the right place to put this bug on?
Comment 5 Daniel Drake 2012-10-30 14:26:05 UTC
This looks like the right place for this bug report.

Next steps would be to look at the vte source code, does vte_buffer_get_text have annotations? (https://live.gnome.org/GObjectIntrospection/Annotations)

If so, look at the vte build logs. It should explain why the function is not available via introspection. It may be choking on that GArray parameter...
Comment 6 S. Daniel Francis 2012-10-30 15:09:09 UTC
(In reply to comment #5)
> Next steps would be to look at the vte source code, does vte_buffer_get_text
> have annotations? 
The problem is bigger:  first  it would consist in check for annotations at vte_view_get_buffer and the VteBuffer type.
Comment 7 Simon Schampijer 2012-11-03 13:13:07 UTC
build log: http://armpkgs.fedoraproject.org/packages/vte3/0.34.1/1.fc18/data/logs/armv7hl/build.log

Current annotation:
{{{
<method name="get_text"
              c:identifier="vte_terminal_get_text"
              introspectable="0">
        <doc xml:whitespace="preserve">Extracts a view of the visible part of the terminal.  If @is_selected is not                                                                      
%NULL, characters will only be read if @is_selected returns %TRUE after being                                                                                                            
passed the column and row, respectively.  A #VteCharAttributes structure                                                                                                                 
is added to @attributes for each byte added to the returned string detailing                                                                                                             
the character's position, colors, and other characteristics.</doc>
        <return-value transfer-ownership="full">
          <doc xml:whitespace="preserve">a newly allocated text string, or %NULL.</doc>
          <type name="utf8" c:type="char*"/>
        </return-value>
        <parameters>
          <parameter name="is_selected"
                     transfer-ownership="none"
                     scope="call"
                     closure="1">
            <doc xml:whitespace="preserve">a #VteSelectionFunc callback</doc>
            <type name="SelectionFunc" c:type="VteSelectionFunc"/>
          </parameter>
          <parameter name="user_data" transfer-ownership="none">
            <doc xml:whitespace="preserve">user data to be passed to the callback</doc>
            <type name="gpointer" c:type="gpointer"/>
          </parameter>
          <parameter name="attributes"
                     direction="out"
                     caller-allocates="0"
                     transfer-ownership="full">
            <doc xml:whitespace="preserve">location for storing text attributes</doc>
            <array zero-terminated="0" name="GLib.Array" c:type="GArray*">
              <type name="CharAttributes"/>
            </array>
          </parameter>
        </parameters>
      </method>
}}}
Comment 8 Simon Schampijer 2012-11-03 14:16:00 UTC
Created attachment 227965 [details] [review]
Move definition of VteCharAttributes up

I found the element-type for the attributes in vte_terminal_get_text vte_terminal_get_text_include_trailing_spaces and vte_terminal_get_text_range strange to be of type "Vte.CharAttributes" and not VteCharAttributes but when I changed it I only got a warning. Then I saw that there was already a warning about "Unknown namespace for identifier 'vte_char_attributes'", so I moved the definition of VteCharAttributes and now those functions are introspectable.

The warning "<unknown>:: Warning: Vte: Unknown namespace for identifier 'vte_char_attributes'" is still there, though.
Comment 9 Behdad Esfahbod 2012-11-20 19:57:12 UTC
Patch looks good.  ChPe, which branches should I commit this to?  Or, can you please commit?
Comment 10 Simon Schampijer 2012-11-20 20:24:22 UTC
If this could get in as a bug fix for vte3-0.34, that would be terrific.
Comment 11 Simon Schampijer 2012-11-28 20:20:51 UTC
Pushed the fix to the vte3-0.34 branch:  http://git.gnome.org/browse/vte/commit/?h=vte-0-34&id=2ba27999b537300f4beb92ca27830fbd4197740e
Comment 12 Behdad Esfahbod 2012-12-01 15:56:12 UTC
Marking fixed.  I assume ChPe will cherry pick from there eventually if it needs to be on other branches.
Comment 13 Gonzalo Odiard 2012-12-10 19:44:09 UTC
I have found two issues trying to use the get_text method in vte with python after apply this patch.

The first is I can't set is_selected as None, the c code can manage it (vte.c line 6293) but the introspection annotations don't allow this.

Can be solved doing:

- * @is_selected: (scope call): a #VteSelectionFunc callback
+ * @is_selected: (scope call) (allow-none): a #VteSelectionFunc callback

The second issue is more difficult to solve in a proper way:

The attributes parameter is marked as:

- * @attributes: (out) (transfer full) (array) (element-type Vte.CharAttributes): location for storing text attributes

but if is a out parameter, I can't pass it as a parameter from python, and the first line using the parameter in the c code is:

line 6298

	if (attributes)
		g_array_set_size (attributes, 0);

Then should be None or a already created GArray.

Right now the application crash when I do:

vte.get_text(None, None)

The only workaround I have found is change:

 - * @attributes: (out) (transfer full) (array) (element-type Vte.CharAttributes): location for storing text attributes
+ * @attributes: (array) (element-type Vte.CharAttributes): location for storing text attributes

and calling from python doing:

vte.get_text(None, None, [])

now the application don't crash, but of course the attributes array is not loaded.

A test case is attached, and a diff to test these changes.
Comment 14 Gonzalo Odiard 2012-12-10 19:46:28 UTC
Created attachment 231197 [details]
Test case using the proposed workaround
Comment 15 Gonzalo Odiard 2012-12-10 19:47:38 UTC
Created attachment 231198 [details] [review]
Path to test the proposed solution
Comment 16 Behdad Esfahbod 2012-12-10 19:51:00 UTC
Please don't report new issues in resolved bugs.  I'll clone this bug for your issues.