Skip to content

Commit

Permalink
add cut function
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias47n9e committed Jul 2, 2015
1 parent 5b005c9 commit 73b9ec3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
1 change: 1 addition & 0 deletions innstereo/gui_layout.glade
Original file line number Diff line number Diff line change
Expand Up @@ -4043,6 +4043,7 @@ customizable grid.</property>
<property name="label" translatable="yes">Cut</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-cut</property>
<signal name="clicked" handler="on_toolbutton_cut_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
Expand Down
42 changes: 35 additions & 7 deletions innstereo/main_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,24 @@ def drag_data_delete(self, treeview, context):
"""
pass

def on_toolbutton_cut_clicked(self, toolbutton):
"""
Cuts the selected layer.
The data is copied into the Gdk.Clipboard and then removed from the
TreeStore.
"""
selection = self.layer_view.get_selection()
model, row_list = selection.get_selected_rows()

if len(row_list) == 0:
return

data = self.copy_layer()
self.clipboard.set_text(data, -1)

self.delete_layer(model, row_list)

def on_toolbutton_copy_clicked(self, toolbutton):
"""
Copies the selected layer data into the Gdk.Clipboard.
Expand Down Expand Up @@ -731,24 +749,34 @@ def on_toolbutton_show_table_clicked(self, widget):
"""
pass

def delete_layer(self, model, row_list):
"""
Deletes all the passed layers and their children.
Expects a model and list of rows. Deletes the rows and all their
children.
__!!__ Currently has no warning message. What happens to data?
"""
for row in reversed(row_list):
itr = model.get_iter(row)
model.remove(itr)

selection = self.layer_view.get_selection()
selection.unselect_all()
self.redraw_plot()

def on_toolbutton_delete_layer_clicked(self, widget):
# pylint: disable=unused-argument
"""
Deltes the currently selected layer(s).
Triggered when the "remove layers" toolbutton is pressed. Deletes all
selected layers.
__!!__ Currently has no warning message. What happens to data?
"""
selection = self.layer_view.get_selection()
model, row_list = selection.get_selected_rows()

for row in reversed(row_list):
itr = model.get_iter(row)
model.remove(itr)

selection.unselect_all()
self.redraw_plot()
self.delete_layer(model, row_list)

def on_toolbutton_plot_properties_clicked(self, widget):
# pylint: disable=unused-argument
Expand Down

0 comments on commit 73b9ec3

Please sign in to comment.