Re: [Vala] Problem with switch statment
- From: Nicolas <c r n a wanadoo fr>
- To: jamie mccrack gmail com, vala-list gnome org
- Subject: Re: [Vala] Problem with switch statment
- Date: Mon, 28 Sep 2009 10:24:50 +0200
Hi Jamie,
Thanks again for your response.
I tried to change my code like this:
def private on_button_press(sender : TreeView, eb : Gdk.EventButton)
: bool
column : Gtk.TreeViewColumn
cell_x, cell_y : int
path : Gtk.TreePath
x : int
x = (int)eb.x
y : int
y = (int)eb.y
selection : Gtk.TreeSelection = treeview.get_selection()
treeview.get_path_at_pos(x, y, out path, out column, out cell_x,
out cell_y)
if(!(selection.count_selected_rows()>0))
selection.select_path(path)
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")
when 3
if (((eb.state & Gdk.ModifierType.SHIFT_MASK) ==
Gdk.ModifierType.SHIFT_MASK) and((eb.state &
Gdk.ModifierType.CONTROL_MASK) == Gdk.ModifierType.CONTROL_MASK))
return false
else
selectioncount : int
selectioncount = selection.count_selected_rows()
if (selectioncount<=1)
selection.unselect_all()
selection.select_path(path)
if use_popup_menu is true
show_treeview_popup(eb.time)
return true
return false
And now i have the message:
treeview.gs:144.9-156.13: warning: unreachable code detected (in fact
it's the line "when 2").
If i delete the "if" in "when 3", same message.
Nicolas.
As I said break statement is redundant in genie case statement - can you
try without it?
(I suspect thats the redundant code)
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]