Lines Matching refs:self
113 def __init__(self): argument
115 self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
116 self.window.set_title("Step Maker Window")
117 self.window.connect("delete-event", self.delete_event)
118 self.window.connect("destroy", self.destroy)
119 self.window.set_default_size(600, 800)
122 self.menu_vbox = gtk.VBox()
123 self.window.add(self.menu_vbox)
124 self.menu_vbox.show()
129 self.menu_vbox.pack_end(frame)
132 self.main_vbox = gtk.VBox(spacing=10)
133 frame.add(self.main_vbox)
134 self.main_vbox.show()
137 self.scrolledwindow = gtk.ScrolledWindow()
138 self.scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC,
140 self.scrolledwindow.set_shadow_type(gtk.SHADOW_NONE)
141 self.main_vbox.pack_start(self.scrolledwindow)
142 self.scrolledwindow.show()
145 self.scrolledwindow.add_with_viewport(table)
149 self.event_box = gtk.EventBox()
150 table.attach(self.event_box, 0, 1, 0, 1, gtk.EXPAND, gtk.EXPAND)
151 self.event_box.show()
152 self.event_box.realize()
155 self.image = gtk.Image()
156 self.event_box.add(self.image)
157 self.image.show()
160 self.data_vbox = gtk.VBox(spacing=10)
161 self.main_vbox.pack_start(self.data_vbox, expand=False)
162 self.data_vbox.show()
165 self.user_vbox = gtk.VBox(spacing=10)
166 self.main_vbox.pack_start(self.user_vbox, expand=False)
167 self.user_vbox.show()
171 self.data_vbox.pack_start(box)
178 self.entry_screendump = gtk.Entry()
179 self.entry_screendump.set_editable(False)
180 box.pack_start(self.entry_screendump)
181 self.entry_screendump.show()
187 self.entry_time = gtk.Entry()
188 self.entry_time.set_editable(False)
189 self.entry_time.set_width_chars(10)
190 box.pack_start(self.entry_time, False)
191 self.entry_time.show()
195 self.data_vbox.pack_start(box)
202 self.entry_comment = gtk.Entry()
203 box.pack_start(self.entry_comment)
204 self.entry_comment.show()
208 self.data_vbox.pack_start(box)
211 self.check_sleep = gtk.CheckButton("Sleep:")
212 self.check_sleep.connect("toggled", self.event_check_sleep_toggled)
213 box.pack_start(self.check_sleep, False)
214 self.check_sleep.show()
216 self.spin_sleep = gtk.SpinButton(gtk.Adjustment(0, 0, 50000, 1, 10, 0),
218 box.pack_start(self.spin_sleep, False)
219 self.spin_sleep.show()
223 self.data_vbox.pack_start(box)
226 self.check_barrier = gtk.CheckButton("Barrier:")
227 self.check_barrier.connect("toggled", self.event_check_barrier_toggled)
228 box.pack_start(self.check_barrier, False)
229 self.check_barrier.show()
235 self.label_barrier_region = gtk.Label("Region:")
236 self.label_barrier_region.set_alignment(0, 0.5)
237 vbox.pack_start(self.label_barrier_region)
238 self.label_barrier_region.show()
240 self.label_barrier_md5sum = gtk.Label("MD5:")
241 self.label_barrier_md5sum.set_alignment(0, 0.5)
242 vbox.pack_start(self.label_barrier_md5sum)
243 self.label_barrier_md5sum.show()
245 self.label_barrier_timeout = gtk.Label("Timeout:")
246 box.pack_start(self.label_barrier_timeout, False)
247 self.label_barrier_timeout.show()
249 self.spin_barrier_timeout = gtk.SpinButton(gtk.Adjustment(0, 0, 50000,
252 box.pack_start(self.spin_barrier_timeout, False)
253 self.spin_barrier_timeout.show()
255 self.check_barrier_optional = gtk.CheckButton("Optional")
256 box.pack_start(self.check_barrier_optional, False)
257 self.check_barrier_optional.show()
261 self.data_vbox.pack_start(box)
273 self.text_buffer = gtk.TextBuffer()
274 self.entry_keys = gtk.TextView(self.text_buffer)
275 self.entry_keys.set_wrap_mode(gtk.WRAP_WORD)
276 self.entry_keys.connect("key-press-event", self.event_key_press)
277 frame.add(self.entry_keys)
278 self.entry_keys.show()
280 self.check_manual = gtk.CheckButton("Manual")
281 self.check_manual.connect("toggled", self.event_manual_toggled)
282 box.pack_start(self.check_manual, False)
283 self.check_manual.show()
286 button.connect("clicked", self.event_clear_clicked)
292 self.data_vbox.pack_start(box)
299 self.button_capture = gtk.Button("Capture")
300 box.pack_start(self.button_capture, False)
301 self.button_capture.show()
303 self.check_mousemove = gtk.CheckButton("Move: ...")
304 box.pack_start(self.check_mousemove, False)
305 self.check_mousemove.show()
307 self.check_mouseclick = gtk.CheckButton("Click: ...")
308 box.pack_start(self.check_mouseclick, False)
309 self.check_mouseclick.show()
311 self.spin_sensitivity = gtk.SpinButton(gtk.Adjustment(1, 1, 100, 1, 10,
314 box.pack_end(self.spin_sensitivity, False)
315 self.spin_sensitivity.show()
321 self.spin_latency = gtk.SpinButton(gtk.Adjustment(10, 1, 500, 1, 10, 0),
323 box.pack_end(self.spin_latency, False)
324 self.spin_latency.show()
330 self.handler_event_box_press = None
331 self.handler_event_box_release = None
332 self.handler_event_box_scroll = None
333 self.handler_event_box_motion = None
334 self.handler_event_box_expose = None
336 self.window.realize()
337 self.window.show()
339 self.clear_state()
343 def message(self, text, title): argument
344 dlg = gtk.MessageDialog(self.window,
355 def question_yes_no(self, text, title): argument
356 dlg = gtk.MessageDialog(self.window,
370 def inputdialog(self, text, title, default_response=""): argument
376 dlg = gtk.MessageDialog(self.window,
399 def filedialog(self, title=None, default_filename=None): argument
400 chooser = gtk.FileChooserDialog(title=title, parent=self.window,
415 def redirect_event_box_input(self, press=None, release=None, scroll=None, argument
417 if self.handler_event_box_press != None: \
418 self.event_box.disconnect(self.handler_event_box_press)
419 if self.handler_event_box_release != None: \
420 self.event_box.disconnect(self.handler_event_box_release)
421 if self.handler_event_box_scroll != None: \
422 self.event_box.disconnect(self.handler_event_box_scroll)
423 if self.handler_event_box_motion != None: \
424 self.event_box.disconnect(self.handler_event_box_motion)
425 if self.handler_event_box_expose != None: \
426 self.event_box.disconnect(self.handler_event_box_expose)
427 self.handler_event_box_press = None
428 self.handler_event_box_release = None
429 self.handler_event_box_scroll = None
430 self.handler_event_box_motion = None
431 self.handler_event_box_expose = None
432 if press != None: self.handler_event_box_press = \
433 self.event_box.connect("button-press-event", press)
434 if release != None: self.handler_event_box_release = \
435 self.event_box.connect("button-release-event", release)
436 if scroll != None: self.handler_event_box_scroll = \
437 self.event_box.connect("scroll-event", scroll)
438 if motion != None: self.handler_event_box_motion = \
439 self.event_box.connect("motion-notify-event", motion)
440 if expose != None: self.handler_event_box_expose = \
441 self.event_box.connect_after("expose-event", expose)
444 def get_keys(self): argument
445 return self.text_buffer.get_text(
446 self.text_buffer.get_start_iter(),
447 self.text_buffer.get_end_iter())
450 def add_key(self, key): argument
451 text = self.get_keys()
455 self.text_buffer.set_text(text)
458 def clear_keys(self): argument
459 self.text_buffer.set_text("")
462 def update_barrier_info(self): argument
463 if self.barrier_selected:
464 self.label_barrier_region.set_text("Selected region: Corner: " + \
465 str(tuple(self.barrier_corner)) + \
467 str(tuple(self.barrier_size)))
469 self.label_barrier_region.set_text("No region selected.")
470 self.label_barrier_md5sum.set_text("MD5: " + self.barrier_md5sum)
473 def update_mouse_click_info(self): argument
474 if self.mouse_click_captured:
475 self.check_mousemove.set_label("Move: " + \
476 str(tuple(self.mouse_click_coords)))
477 self.check_mouseclick.set_label("Click: button %d" %
478 self.mouse_click_button)
480 self.check_mousemove.set_label("Move: ...")
481 self.check_mouseclick.set_label("Click: ...")
484 def clear_state(self, clear_screendump=True): argument
486 self.entry_time.set_text("unknown")
489 self.clear_image()
491 self.entry_screendump.set_text("")
493 self.entry_comment.set_text("")
495 self.check_sleep.set_active(True)
496 self.check_sleep.set_active(False)
497 self.spin_sleep.set_value(10)
499 self.clear_barrier_state()
501 self.check_manual.set_active(False)
502 self.clear_keys()
504 self.check_mousemove.set_sensitive(False)
505 self.check_mouseclick.set_sensitive(False)
506 self.check_mousemove.set_active(False)
507 self.check_mouseclick.set_active(False)
508 self.mouse_click_captured = False
509 self.mouse_click_coords = [0, 0]
510 self.mouse_click_button = 0
511 self.update_mouse_click_info()
514 def clear_barrier_state(self): argument
515 self.check_barrier.set_active(True)
516 self.check_barrier.set_active(False)
517 self.check_barrier_optional.set_active(False)
518 self.spin_barrier_timeout.set_value(10)
519 self.barrier_selection_started = False
520 self.barrier_selected = False
521 self.barrier_corner0 = [0, 0]
522 self.barrier_corner1 = [0, 0]
523 self.barrier_corner = [0, 0]
524 self.barrier_size = [0, 0]
525 self.barrier_md5sum = ""
526 self.update_barrier_info()
529 def set_image(self, w, h, data): argument
530 (self.image_width, self.image_height, self.image_data) = (w, h, data)
531 self.image.set_from_pixbuf(gtk.gdk.pixbuf_new_from_data(
534 hscrollbar = self.scrolledwindow.get_hscrollbar()
536 vscrollbar = self.scrolledwindow.get_vscrollbar()
540 def set_image_from_file(self, filename): argument
544 return self.clear_image()
546 self.set_image(w, h, data)
549 def clear_image(self): argument
550 self.image.clear()
551 self.image_width = 0
552 self.image_height = 0
553 self.image_data = ""
556 def update_screendump_id(self, data_dir): argument
557 if not self.image_data:
560 scrdump_md5sum = ppm_utils.image_md5sum(self.image_width,
561 self.image_height,
562 self.image_data)
568 self.entry_screendump.set_text(scrdump_id)
571 def get_step_lines(self, data_dir=None): argument
572 if self.check_barrier.get_active() and not self.barrier_selected:
573 self.message("No barrier region selected.", "Error")
579 if self.entry_time.get_text():
580 str += " " + self.entry_time.get_text()
585 if self.image_data:
586 str += "screendump %s\n" % self.entry_screendump.get_text()
589 if self.entry_comment.get_text():
590 str += "# %s\n" % self.entry_comment.get_text()
593 if self.check_sleep.get_active():
594 str += "sleep %d\n" % self.spin_sleep.get_value()
597 if self.check_barrier.get_active():
599 self.barrier_size[0], self.barrier_size[1],
600 self.barrier_corner[0], self.barrier_corner[1],
601 self.barrier_md5sum, self.spin_barrier_timeout.get_value())
602 if self.check_barrier_optional.get_active():
607 keys_to_send = self.get_keys().split()
609 str += "# Sending keys: %s\n" % self.get_keys()
620 if self.check_mousemove.get_active():
621 str += "mousemove %d %d\n" % (self.mouse_click_coords[0],
622 self.mouse_click_coords[1])
625 if self.check_mouseclick.get_active():
629 str += "mouseclick %d\n" % dict[self.mouse_click_button]
632 if data_dir and self.image_data:
638 self.entry_screendump.get_text())
643 self.image_width,
644 self.image_height,
645 self.image_data)
647 self.message("Could not write screendump file.", "Error")
669 def set_state_from_step_lines(self, str, data_dir, warn=True): argument
670 self.clear_state()
678 and not self.entry_comment.get_text() \
681 self.entry_comment.set_text(line.strip("#").strip())
685 self.entry_time.set_text(words[1])
688 self.entry_screendump.set_text(words[1])
689 self.set_image_from_file(os.path.join(data_dir, words[1]))
692 self.spin_sleep.set_value(int(words[1]))
693 self.check_sleep.set_active(True)
696 self.add_key(words[1])
699 self.add_key("$%s" % words[1])
702 self.mouse_click_captured = True
703 self.mouse_click_coords = [int(words[1]), int(words[2])]
704 self.update_mouse_click_info()
707 self.mouse_click_captured = True
708 self.mouse_click_button = int(words[1])
709 self.update_mouse_click_info()
713 self.barrier_corner = [int(words[3]), int(words[4])]
714 self.barrier_size = [int(words[1]), int(words[2])]
716 self.barrier_corner0 = self.barrier_corner
717 self.barrier_corner1 = [self.barrier_corner[0] +
718 self.barrier_size[0] - 1,
719 self.barrier_corner[1] +
720 self.barrier_size[1] - 1]
722 self.barrier_md5sum = words[5]
724 self.barrier_selection_started = True
725 self.barrier_selected = True
727 self.update_barrier_info()
729 self.check_barrier.set_active(True)
731 self.spin_barrier_timeout.set_value(int(words[6]))
733 self.check_barrier_optional.set_active(words[-1] == "optional")
735 self.event_box.queue_draw()
741 self.image_width, self.image_height,
742 self.image_data, self.barrier_corner[0],
743 self.barrier_corner[1], self.barrier_size[0],
744 self.barrier_size[1])
745 if computed_md5sum != self.barrier_md5sum:
746 self.message("Computed MD5 sum (%s) differs from MD5"
748 (computed_md5sum, self.barrier_md5sum),
753 def delete_event(self, widget, event): argument
756 def destroy(self, widget): argument
759 def event_check_barrier_toggled(self, widget): argument
760 if self.check_barrier.get_active():
761 self.redirect_event_box_input(
762 self.event_button_press,
763 self.event_button_release,
766 self.event_expose)
767 self.event_box.queue_draw()
768 self.event_box.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.CROSSHAIR))
769 self.label_barrier_region.set_sensitive(True)
770 self.label_barrier_md5sum.set_sensitive(True)
771 self.label_barrier_timeout.set_sensitive(True)
772 self.spin_barrier_timeout.set_sensitive(True)
773 self.check_barrier_optional.set_sensitive(True)
775 self.redirect_event_box_input()
776 self.event_box.queue_draw()
777 self.event_box.window.set_cursor(None)
778 self.label_barrier_region.set_sensitive(False)
779 self.label_barrier_md5sum.set_sensitive(False)
780 self.label_barrier_timeout.set_sensitive(False)
781 self.spin_barrier_timeout.set_sensitive(False)
782 self.check_barrier_optional.set_sensitive(False)
784 def event_check_sleep_toggled(self, widget): argument
785 if self.check_sleep.get_active():
786 self.spin_sleep.set_sensitive(True)
788 self.spin_sleep.set_sensitive(False)
790 def event_manual_toggled(self, widget): argument
791 self.entry_keys.grab_focus()
793 def event_clear_clicked(self, widget): argument
794 self.clear_keys()
795 self.entry_keys.grab_focus()
797 def event_expose(self, widget, event): argument
798 if not self.barrier_selection_started:
800 (corner, size) = corner_and_size_clipped(self.barrier_corner0,
801 self.barrier_corner1,
802 self.event_box.size_request())
803 gc = self.event_box.window.new_gc(line_style=gtk.gdk.LINE_DOUBLE_DASH,
808 self.event_box.window.draw_rectangle(
813 def event_drag_motion(self, widget, event): argument
814 old_corner1 = self.barrier_corner1
815 self.barrier_corner1 = [int(event.x), int(event.y)]
816 (corner, size) = corner_and_size_clipped(self.barrier_corner0,
817 self.barrier_corner1,
818 self.event_box.size_request())
819 (old_corner, old_size) = corner_and_size_clipped(self.barrier_corner0,
821 self.event_box.size_request())
827 self.event_box.queue_draw_area(corner0[0], corner0[1], size[0], size[1])
829 def event_button_press(self, widget, event): argument
830 (corner, size) = corner_and_size_clipped(self.barrier_corner0,
831 self.barrier_corner1,
832 self.event_box.size_request())
833 self.event_box.queue_draw_area(corner[0], corner[1], size[0], size[1])
834 self.barrier_corner0 = [int(event.x), int(event.y)]
835 self.barrier_corner1 = [int(event.x), int(event.y)]
836 self.redirect_event_box_input(
837 self.event_button_press,
838 self.event_button_release,
840 self.event_drag_motion,
841 self.event_expose)
842 self.barrier_selection_started = True
844 def event_button_release(self, widget, event): argument
845 self.redirect_event_box_input(
846 self.event_button_press,
847 self.event_button_release,
850 self.event_expose)
851 (self.barrier_corner, self.barrier_size) = \
852 corner_and_size_clipped(self.barrier_corner0, self.barrier_corner1,
853 self.event_box.size_request())
854 self.barrier_md5sum = ppm_utils.get_region_md5sum(
855 self.image_width, self.image_height, self.image_data,
856 self.barrier_corner[0], self.barrier_corner[1],
857 self.barrier_size[0], self.barrier_size[1])
858 self.barrier_selected = True
859 self.update_barrier_info()
861 def event_key_press(self, widget, event): argument
862 if self.check_manual.get_active():
865 self.add_key(str)
896 def __init__(self, filename=None): argument
897 StepMakerWindow.__init__(self)
899 self.steps_filename = None
900 self.steps = []
907 self.window.add_accel_group(accelgroup)
915 self.quit),
917 self.open_steps_file),
919 'Copy current step to user specified position', self.copy_step),
921 'Delete current step', self.event_remove_clicked),
923 'Insert new step before current step', self.insert_before),
925 'Insert new step after current step', self.insert_after),
928 self.insert_steps_before),
931 self.insert_steps_after),
933 'Move unused PPM files to a backup directory', self.cleanup),
951 create_shortcut("Next", self.event_next_clicked, "Page_Down")
952 create_shortcut("Previous", self.event_prev_clicked, "Page_Up")
958 uimanager.add_ui_from_string(self.ui)
962 self.menu_vbox.pack_start(menubar, False)
965 self.menu_edit = uimanager.get_widget('/MenuBar/Edit')
966 self.menu_edit.set_sensitive(False)
969 self.menu_insert = uimanager.get_widget('/MenuBar/Insert')
970 self.menu_insert.set_sensitive(False)
973 self.menu_tools = uimanager.get_widget('/MenuBar/Tools')
974 self.menu_tools.set_sensitive(False)
978 self.user_vbox.pack_start(hbox)
981 self.button_first = gtk.Button(stock=gtk.STOCK_GOTO_FIRST)
982 self.button_first.connect("clicked", self.event_first_clicked)
983 hbox.pack_start(self.button_first)
984 self.button_first.show()
987 self.button_prev = gtk.Button(stock=gtk.STOCK_GO_BACK)
988 self.button_prev.connect("clicked", self.event_prev_clicked)
989 hbox.pack_start(self.button_prev)
990 self.button_prev.show()
992 self.label_step = gtk.Label("Step:")
993 hbox.pack_start(self.label_step, False)
994 self.label_step.show()
996 self.entry_step_num = gtk.Entry()
997 self.entry_step_num.connect("activate", self.event_entry_step_activated)
998 self.entry_step_num.set_width_chars(3)
999 hbox.pack_start(self.entry_step_num, False)
1000 self.entry_step_num.show()
1003 self.button_next = gtk.Button(stock=gtk.STOCK_GO_FORWARD)
1004 self.button_next.connect("clicked", self.event_next_clicked)
1005 hbox.pack_start(self.button_next)
1006 self.button_next.show()
1008 self.button_last = gtk.Button(stock=gtk.STOCK_GOTO_LAST)
1009 self.button_last.connect("clicked", self.event_last_clicked)
1010 hbox.pack_start(self.button_last)
1011 self.button_last.show()
1015 self.user_vbox.pack_start(hbox)
1018 self.button_save = gtk.Button("_Save current step")
1019 self.button_save.connect("clicked", self.event_save_clicked)
1020 hbox.pack_start(self.button_save)
1021 self.button_save.show()
1023 self.button_remove = gtk.Button("_Delete current step")
1024 self.button_remove.connect("clicked", self.event_remove_clicked)
1025 hbox.pack_start(self.button_remove)
1026 self.button_remove.show()
1028 self.button_replace = gtk.Button("_Replace screendump")
1029 self.button_replace.connect("clicked", self.event_replace_clicked)
1030 hbox.pack_start(self.button_replace)
1031 self.button_replace.show()
1034 self.button_capture.set_sensitive(False)
1035 self.spin_latency.set_sensitive(False)
1036 self.spin_sensitivity.set_sensitive(False)
1039 self.main_vbox.set_sensitive(False)
1042 self.window.set_title("Step Editor")
1046 def delete_event(self, widget, event): argument
1048 self.verify_save()
1050 def event_first_clicked(self, widget): argument
1051 if not self.steps:
1054 self.verify_save()
1056 self.set_step(0)
1058 def event_last_clicked(self, widget): argument
1059 if not self.steps:
1062 self.verify_save()
1064 self.set_step(len(self.steps) - 1)
1066 def event_prev_clicked(self, widget): argument
1067 if not self.steps:
1070 self.verify_save()
1072 index = self.current_step_index - 1
1073 if self.steps:
1074 index = index % len(self.steps)
1075 self.set_step(index)
1077 def event_next_clicked(self, widget): argument
1078 if not self.steps:
1081 self.verify_save()
1083 index = self.current_step_index + 1
1084 if self.steps:
1085 index = index % len(self.steps)
1086 self.set_step(index)
1088 def event_entry_step_activated(self, widget): argument
1089 if not self.steps:
1091 step_index = self.entry_step_num.get_text()
1095 if step_index == self.current_step_index:
1097 self.verify_save()
1098 self.set_step(step_index)
1100 def event_save_clicked(self, widget): argument
1101 if not self.steps:
1103 self.save_step()
1105 def event_remove_clicked(self, widget): argument
1106 if not self.steps:
1108 if not self.question_yes_no("This will modify the steps file."
1112 del self.steps[self.current_step_index]
1114 self.write_steps_file(self.steps_filename)
1116 self.set_step(self.current_step_index)
1118 def event_replace_clicked(self, widget): argument
1119 if not self.steps:
1122 current_filename = os.path.join(self.steps_data_dir,
1123 self.entry_screendump.get_text())
1124 filename = self.filedialog("Choose PPM image file",
1129 self.message("Not a valid PPM image file.", "Error")
1131 self.clear_image()
1132 self.clear_barrier_state()
1133 self.set_image_from_file(filename)
1134 self.update_screendump_id(self.steps_data_dir)
1138 def open_steps_file(self, action): argument
1140 self.verify_save()
1142 current_filename = self.steps_filename
1143 filename = self.filedialog("Open steps file",
1147 self.set_steps_file(filename)
1149 def quit(self, action): argument
1151 self.verify_save()
1155 def copy_step(self, action): argument
1156 if not self.steps:
1158 self.verify_save()
1159 self.set_step(self.current_step_index)
1161 step_index = self.inputdialog("Copy step to position:",
1163 str(self.current_step_index + 2))
1168 step = self.steps[self.current_step_index]
1170 self.steps.insert(step_index, step)
1172 self.set_step(step_index)
1174 self.write_steps_file(self.steps_filename)
1176 def insert_before(self, action): argument
1177 if not self.steps_filename:
1179 if not self.question_yes_no("This will modify the steps file."
1182 self.verify_save()
1183 step_index = self.current_step_index
1185 self.clear_state()
1186 step = self.get_step_lines()
1188 self.steps.insert(step_index, step)
1190 self.set_step(step_index)
1192 self.write_steps_file(self.steps_filename)
1194 def insert_after(self, action): argument
1195 if not self.steps_filename:
1197 if not self.question_yes_no("This will modify the steps file."
1200 self.verify_save()
1201 step_index = self.current_step_index + 1
1203 self.clear_state()
1204 step = self.get_step_lines()
1206 self.steps.insert(step_index, step)
1208 self.set_step(step_index)
1210 self.write_steps_file(self.steps_filename)
1212 def insert_steps(self, filename, index): argument
1214 (steps, header) = self.read_steps_file(filename)
1218 self.set_state_from_step_lines(step, data_dir, warn=False)
1219 step = self.get_step_lines(self.steps_data_dir)
1222 self.steps[index:index] = steps
1224 self.write_steps_file(self.steps_filename)
1226 def insert_steps_before(self, action): argument
1227 if not self.steps_filename:
1230 current_filename = self.steps_filename
1231 filename = self.filedialog("Choose steps file",
1235 self.verify_save()
1237 step_index = self.current_step_index
1239 self.insert_steps(filename, step_index)
1241 self.set_step(step_index)
1243 def insert_steps_after(self, action): argument
1244 if not self.steps_filename:
1247 current_filename = self.steps_filename
1248 filename = self.filedialog("Choose steps file",
1252 self.verify_save()
1254 step_index = self.current_step_index + 1
1256 self.insert_steps(filename, step_index)
1258 self.set_step(step_index)
1260 def cleanup(self, action): argument
1261 if not self.steps_filename:
1263 if not self.question_yes_no("All unused PPM files will be moved to a"
1268 current_step_index = self.current_step_index
1270 backup_dir = os.path.join(self.steps_data_dir, "backup")
1275 for filename in glob.glob(os.path.join(self.steps_data_dir,
1279 for step in self.steps:
1280 self.set_state_from_step_lines(step, backup_dir, warn=False)
1281 self.get_step_lines(self.steps_data_dir)
1283 used_files = os.listdir(self.steps_data_dir)
1288 self.set_step(current_step_index)
1290 self.message("All unused PPM files may be found at %s." %
1296 def read_steps_file(self, filename): argument
1317 def set_steps_file(self, filename): argument
1319 (self.steps, self.header) = self.read_steps_file(filename)
1321 self.message("Cannot read file %s." % filename, "Error")
1324 self.steps_filename = filename
1325 self.steps_data_dir = ppm_utils.get_data_dir(filename)
1327 self.set_step(0)
1329 def set_step(self, index): argument
1333 if index > len(self.steps) - 1:
1334 index = len(self.steps) - 1
1337 self.menu_edit.set_sensitive(True)
1338 self.menu_insert.set_sensitive(True)
1339 self.menu_tools.set_sensitive(True)
1342 if self.steps == []:
1343 self.current_step_index = index
1344 self.current_step = None
1346 self.window.set_title("Step Editor -- %s" %
1347 os.path.basename(self.steps_filename))
1349 self.entry_step_num.set_text("")
1351 self.clear_state()
1353 self.main_vbox.set_sensitive(False)
1356 self.current_step_index = index
1357 self.current_step = self.steps[index]
1359 self.window.set_title("Step Editor -- %s -- step %d" %
1360 (os.path.basename(self.steps_filename),
1363 self.entry_step_num.set_text(str(self.current_step_index + 1))
1365 self.set_state_from_step_lines(self.current_step, self.steps_data_dir)
1367 self.main_vbox.set_sensitive(True)
1370 self.current_step = self.get_step_lines()
1372 def verify_save(self): argument
1373 if not self.steps:
1376 if self.get_step_lines() != self.current_step:
1377 if self.question_yes_no("Step contents have been modified."
1379 self.save_step()
1381 def save_step(self): argument
1382 lines = self.get_step_lines(self.steps_data_dir)
1384 self.steps[self.current_step_index] = lines
1385 self.current_step = lines
1386 self.write_steps_file(self.steps_filename)
1388 def write_steps_file(self, filename): argument
1390 file.write(self.header)
1391 for step in self.steps: