-------- Original-Nachricht --------
> Datum: Mon, 30 Apr 2012 14:30:37 +0200
> Von: Jean Brefort <[email protected]>
> An: [email protected]
> CC: [email protected]
> Betreff: Re: Gnumeric Python: get position of the current selected cell

> It is not possible in 1.10 but might be in next version if somebody
> helps with porting the Python plugins to using introspection.
> 
> Regards,
> Jean
> 

Ah ok, thanks for the reply.

I have a partial solution (this is a rather ugly thing, because I almost don't 
know anything about gnumeric internals). It took really long time to geht that 
running! ;)

The drawback is, it uses always only the first sheet.

So it works in following manner:
it should always copy the entered text of the cell above into the current cell.

I have patched /gnumeric-1.10.17/plugins/python-loader/py-gnumeric.c:

...

py_sheet_cell_active_pos_method (py_Sheet_object *self, PyObject *args);
static PyObject *

...

  {(char *) "cell_active_pos",
   (PyCFunction) py_sheet_cell_active_pos_method,        METH_VARARGS},
...


#include "sheet-view.h"



static PyObject *
py_sheet_cell_active_pos_method (py_Sheet_object *self, PyObject *args)
{
  GnmCellPos cell_pos;

  GPtrArray   *views = self->sheet->sheet_views;

  SheetView *view = g_ptr_array_index (views, 0); // 0?????

  cell_pos = view->edit_pos;

  return py_new_CellPos_object (&cell_pos);
}


and my py file looks like: (only that function):

def f_fill(gui):
    wb  = gui.get_workbook()

    s=wb.sheets()[0]

    z=s.cell_active_pos()
    tup = z.get_tuple()
    if tup[1] == 0:
        print "this is the upper cell, no cell above"
        return #there is no value up there
    c = s.cell_fetch(tup[0], tup[1]-1)
    entered_text = c.get_entered_text()
    s[tup[0],tup[1]].set_text(entered_text)


If I bind it to a shortcut key, it is rather efficient.

Is there any way to bind a function permanently to a shortcut?

Do you have any hint, how to get the "active" (the currently selected sheet)? 
and have the function everywhere?
-- 
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!                          
        
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a


-- 
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!                          
        
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a
_______________________________________________
gnumeric-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gnumeric-list

Reply via email to