Re: [Vala] Problem with switch statment



On Sun, 2009-09-27 at 20:23 +0200, Nicolas wrote:
Hi Jamie,
Thanks for your response.
My function work but i have this message when building:

treeview.gs:143.9-158.13: warning: unreachable code detected
Compilation succeeded - 1 warning(s)

This is the code:

        case eb.button
            when 1
                if(selection.count_selected_rows()<=1)
                    return false
                else
                    if selection.path_is_selected(path)
                        if (((eb.state & Gdk.ModifierType.SHIFT_MASK) == 
Gdk.ModifierType.SHIFT_MASK) and((eb.state & 
Gdk.ModifierType.CONTROL_MASK) == Gdk.ModifierType.CONTROL_MASK))
                            selection.unselect_path(path)
                        else if(!(((eb.state & 
Gdk.ModifierType.SHIFT_MASK) == Gdk.ModifierType.SHIFT_MASK) and 
((eb.state & Gdk.ModifierType.CONTROL_MASK) == 
Gdk.ModifierType.CONTROL_MASK)))
                            return true
                        return true
                   return false
            when 2
                print("button 2 clicked\n")
                break

As I said break statement is redundant in genie case statement - can you
try without it?

(I suspect thats the redundant code)



Another question i need to use a GLib.List, i know under vala, it's:

GLib.List<TreePath> mylist;

But how to use it with genie ?



mylist : GLib.List of TreePath

you might want 
mylist : weak GLib.List of TreePath 

if you are using it for selection in a tree view (which I did recently)

see method GetSelectedPath in
http://git.gnome.org/cgit/tracker/tree/src/tracker-search-tool/tracker-result-grid.gs

jamie





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]