@@ -573,48 +573,15 @@ def on_suggestion_selection_changed(self, selection, word):
573573 self .get_cursor_iter ())
574574 self .text_buffer .insert_at_cursor (word )
575575
576- def pastebin (self , widget ):
577- """Upload to a pastebin and display the URL in the status bar."""
576+
577+ def ask_confirmation (self , q ):
578+ dialog = gtk .MessageDialog (None , gtk .DIALOG_MODAL , gtk .MESSAGE_INFO , gtk .BUTTONS_YES_NO , q )
579+ response = True if dialog .run () == gtk .RESPONSE_YES else False
580+ dialog .destroy ()
581+ return response
578582
579- # FIXME cleanup
580- response = False
581-
582- if self .config .pastebin_confirm :
583- dialog = gtk .MessageDialog (None , gtk .DIALOG_MODAL , gtk .MESSAGE_INFO , gtk .BUTTONS_YES_NO ,
584- "Pastebin buffer?" )
585- response = True if dialog .run () == gtk .RESPONSE_YES else False
586- dialog .destroy ()
587- else :
588- response = True
589-
590- if not response :
591- self .statusbar .message ("Pastebin aborted" )
592- return
593- # end FIXME
594-
595- pasteservice = ServerProxy (self .config .pastebin_url )
596-
597- s = self .stdout_hist
598-
599- if s == self .prev_pastebin_content :
600- self .statusbar .message ('Duplicate pastebin. Previous URL: ' +
601- self .prev_pastebin_url )
602- return
603-
604- self .prev_pastebin_content = s
605-
606- self .statusbar .message ('Posting data to pastebin...' )
607- try :
608- paste_id = pasteservice .pastes .newPaste ('pycon' , s )
609- except XMLRPCError , e :
610- self .statusbar .message ('Upload failed: %s' % (str (e ), ) )
611- return
612-
613- paste_url_template = Template (self .config .pastebin_show_url )
614- paste_id = urlquote (paste_id )
615- paste_url = paste_url_template .safe_substitute (paste_id = paste_id )
616- self .prev_pastebin_url = paste_url
617- self .statusbar .message ('Pastebin URL: %s' % (paste_url , ), 10 )
583+ def do_paste (self , widget ):
584+ self .pastebin ()
618585
619586 def write (self , s ):
620587 """For overriding stdout defaults"""
@@ -690,8 +657,7 @@ def set_cursor_to_valid_insert_position(self):
690657 if line_start_iter .compare (cursor_iter ) > 0 :
691658 self .text_buffer .place_cursor (line_start_iter )
692659
693- @property
694- def stdout_hist (self ):
660+ def getstdout (self ):
695661 bounds = self .text_buffer .get_bounds ()
696662 text = self .text_buffer .get_text (bounds [0 ], bounds [1 ])
697663 return text
@@ -773,7 +739,7 @@ def main(args=None):
773739 filem .set_submenu (filemenu )
774740
775741 pastebin = gtk .MenuItem ("Pastebin" )
776- pastebin .connect ("activate" , repl_widget .pastebin )
742+ pastebin .connect ("activate" , repl_widget .do_paste )
777743 filemenu .append (pastebin )
778744
779745 exit = gtk .MenuItem ("Exit" )
0 commit comments