Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAneesh Dogra <lionaneesh@gmail.com>2012-12-05 19:51:14 (GMT)
committer Aneesh Dogra <lionaneesh@gmail.com>2012-12-05 19:54:10 (GMT)
commitee36d676007bda44c744f10be189aa54338776eb (patch)
tree88283d082bf8a20599e2d1a6187df3853a0c0b1f
parenta87bb9b7ca6f1b6394d08ca08c69f0bfb5860e97 (diff)
Add functionality to export plots to clipboard.
Fix #2701
-rw-r--r--calculate.py16
-rw-r--r--layout.py60
2 files changed, 61 insertions, 15 deletions
diff --git a/calculate.py b/calculate.py
index 79f362f..196974f 100644
--- a/calculate.py
+++ b/calculate.py
@@ -416,7 +416,6 @@ class Calculate(ShareableActivity):
tree: the parsed tree, this will be used to set the label variable
so that the equation can be used symbolicaly.
"""
-
if eq.equation is not None and len(eq.equation) > 0:
if prepend:
self.old_eqs.insert(0, eq)
@@ -733,12 +732,17 @@ class Calculate(ShareableActivity):
self.select_reason = self.SELECT_SELECT
def text_copy(self):
- str = self.text_entry.get_text()
- sel = self.text_entry.get_selection_bounds()
+ if self.layout.graph_selected != False:
+ print "\n\nGraph Copy!\n\n"
+ self.clipboard.set_image(self.layout.graph_selected.child.get_pixbuf())
+ self.layout.toggle_select_graph(self.layout.graph_selected)
+ else:
+ str = self.text_entry.get_text()
+ sel = self.text_entry.get_selection_bounds()
# _logger.info('text_copy, sel: %r, str: %s', sel, str)
- if len(sel) == 2:
- (start, end) = sel
- self.clipboard.set_text(str[start:end])
+ if len(sel) == 2:
+ (start, end) = sel
+ self.clipboard.set_text(str[start:end])
def get_clipboard_text(self):
text = self.clipboard.wait_for_text()
diff --git a/layout.py b/layout.py
index 5a77357..c6377fb 100644
--- a/layout.py
+++ b/layout.py
@@ -37,6 +37,7 @@ class CalcLayout:
self._showing_history = True
self._showing_all_history = True
self._var_textviews = {}
+ self.graph_selected = False
self.create_dialog()
@@ -295,34 +296,75 @@ class CalcLayout:
self.variable_vbox.hide()
self.history_vbox.show()
+ def toggle_select_graph(self, widget, host=None):
+ if not self.graph_selected:
+ widget.set_visible_window(True)
+ widget.set_above_child(True)
+ self.graph_selected = widget
+ white = gtk.gdk.color_parse('white')
+ widget.modify_bg(gtk.STATE_NORMAL, white)
+ else:
+ widget.set_visible_window(False)
+ self.graph_selected = False
+
def add_equation(self, textview, own, prepend=False):
"""Add a gtk.TextView of an equation to the history_vbox."""
+ GraphEventBox = None
+ if isinstance(textview, gtk.Image):
+ # Add the image inside the eventBox
+ GraphEventBox = gtk.EventBox()
+ GraphEventBox.add(textview)
+ GraphEventBox.set_visible_window(False)
+ GraphEventBox.connect('button_press_event', self.toggle_select_graph)
+ GraphEventBox.show()
+
if prepend:
- self.history_vbox.pack_start(textview, False, True)
- self.history_vbox.reorder_child(textview, 0)
+ if GraphEventBox:
+ self.history_vbox.pack_start(GraphEventBox, False, True)
+ self.history_vbox.reorder_child(GraphEventBox, 0)
+ else:
+ self.history_vbox.pack_start(textview, False, True)
+ self.history_vbox.reorder_child(textview, 0)
else:
- self.history_vbox.pack_end(textview, False, True)
+ if GraphEventBox:
+ self.history_vbox.pack_end(GraphEventBox, False, True)
+ else:
+ self.history_vbox.pack_end(textview, False, True)
if own:
- self._own_equations.append(textview)
- textview.show()
+ if GraphEventBox:
+ self._own_equations.append(GraphEventBox)
+ GraphEventBox.child.show()
+ else:
+ self._own_equations.append(textview)
+ textview.show()
else:
- self._other_equations.append(textview)
if self._showing_all_history:
- textview.show()
+ if GraphEventBox:
+ self._other_equations.append(GraphEventBox)
+ GraphEventBox.child.show()
+ else:
+ self._other_equations.append(textview)
+ textview.show()
def show_all_history(self):
"""Show both owned and other equations."""
self._showing_all_history = True
for key in self._other_equations:
- key.show()
+ if isinstance(key, gtk.EventBox):
+ key.child.show()
+ else:
+ key.show()
def show_own_history(self):
"""Show only owned equations."""
self._showing_all_history = False
for key in self._other_equations:
- key.hide()
+ if isinstance(key, gtk.EventBox):
+ key.child.hide()
+ else:
+ key.hide()
def add_variable(self, varname, textview):
"""Add a gtk.TextView of a variable to the variable_vbox."""