Need help to set a cursor/focus on treeview row!

View: New views
4 Messages — Rating Filter:   Alert me  

Need help to set a cursor/focus on treeview row!

by Daniel B. Thurman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I am learning, so please bear with me!

I have the following code:

    def expandHome(self, model, iter=None, defaultHome=None):
        ''' expand user's home directory '''
        if not defaultHome:
            return
        ran = model.iter_n_children(iter)
        for i in range(ran):
            iter_n_child = model.iter_nth_child(iter, i)
            path = model.get_path(iter_n_child)
            pn = model[path][1]
            idx = defaultHome.find(pn)
            if idx > -1:
                Dbg.dPrint(" + File=%s" % pn)
                StoreTools.append_path(model, iter=iter_n_child)
                Display.tv.expand_row(path, False)
                self.expandHome(model, iter_n_child, defaultHome)
        # Set cursor selection to the homepath here
        Display.tv.set_cursor(path, focus_column=None, start_editing=False)

The treestore is saved into a treeview, and the
treeview is saved into a scrolledwindow.

The above code expands the treeview on the user's
home directory and it works, and the last step is to
set the cursor or focus on the user's home directory
of which I am not able to do.  The code:

Display.tv.set_cursor(path, focus_column=None, start_editing=False)

is a feeble attempt to do that and it is not working for
me.

Please advise?

Thanks!
Dan

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@...
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Need help to set a cursor/focus on treeview row!

by Daniel B. Thurman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 10/30/2009 05:48 PM, Daniel B. Thurman wrote:

> I am learning, so please bear with me!
>
> I have the following code:
>
>     def expandHome(self, model, iter=None, defaultHome=None):
>         ''' expand user's home directory '''
>         if not defaultHome:
>             return
>         ran = model.iter_n_children(iter)
>         for i in range(ran):
>             iter_n_child = model.iter_nth_child(iter, i)
>             path = model.get_path(iter_n_child)
>             pn = model[path][1]
>             idx = defaultHome.find(pn)
>             if idx > -1:
>                 Dbg.dPrint(" + File=%s" % pn)
>                 StoreTools.append_path(model, iter=iter_n_child)
>                 Display.tv.expand_row(path, False)
>                 self.expandHome(model, iter_n_child, defaultHome)
>         # Set cursor selection to the homepath here
>         Display.tv.set_cursor(path, focus_column=None, start_editing=False)
>
> The treestore is saved into a treeview, and the
> treeview is saved into a scrolledwindow.
>
> The above code expands the treeview on the user's
> home directory and it works, and the last step is to
> set the cursor or focus on the user's home directory
> of which I am not able to do.  The code:
>
> Display.tv.set_cursor(path, focus_column=None, start_editing=False)
>
> is a feeble attempt to do that and it is not working for
> me.
>
> Please advise?
>  
I wanted to add a bit of clarification.  The goal is that once
the user's home directory is expanded, I wanted to bring the
expanded tree of "/home/some-user" into view in the scrolled
window, centered, so I may have the wrong method entirely.

Thanks!
Dan

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@...
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Need help to set a cursor/focus on treeview row!

by David Nečas (Yeti)-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, Oct 31, 2009 at 10:06:12AM -0700, Daniel B. Thurman wrote:
> I wanted to add a bit of clarification.  The goal is that once
> the user's home directory is expanded, I wanted to bring the
> expanded tree of "/home/some-user" into view in the scrolled
> window, centered, so I may have the wrong method entirely.

You are probably looking for this:

http://library.gnome.org/devel/gtk/stable/GtkTreeView.html#gtk-tree-view-scroll-to-cell

Yeti

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@...
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Need help to set a cursor/focus on treeview row!

by Daniel B. Thurman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 10/30/2009 05:48 PM, Daniel B. Thurman wrote:

> I am learning, so please bear with me!
>
> I have the following code:
>
>     def expandHome(self, model, iter=None, defaultHome=None):
>         ''' expand user's home directory '''
>         if not defaultHome:
>             return
>         ran = model.iter_n_children(iter)
>         for i in range(ran):
>             iter_n_child = model.iter_nth_child(iter, i)
>             path = model.get_path(iter_n_child)
>             pn = model[path][1]
>             idx = defaultHome.find(pn)
>             if idx > -1:
>                 Dbg.dPrint(" + File=%s" % pn)
>                 StoreTools.append_path(model, iter=iter_n_child)
>                 Display.tv.expand_row(path, False)
>                 self.expandHome(model, iter_n_child, defaultHome)
>         # Set cursor selection to the homepath here
>         Display.tv.set_cursor(path, focus_column=None, start_editing=False)
>
> The treestore is saved into a treeview, and the
> treeview is saved into a scrolledwindow.
>
> The above code expands the treeview on the user's
> home directory and it works, and the last step is to
> set the cursor or focus on the user's home directory
> of which I am not able to do.  The code:
>
> Display.tv.set_cursor(path, focus_column=None, start_editing=False)
>
> is a feeble attempt to do that and it is not working for
> me.
>
> Please advise?
>
> Thanks!
> Dan
>
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list@...
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>  
Never mind, I solved it.

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@...
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list