emesene forum
March 15, 2010, 07:54:29 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: REPORT ANY ISSUE HERE - PLEASE CHECK IF THE PROBLEM HAS ALREADY BEEN REPORTED FIRST -- THANKS
 
  Home   Forum   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: [IDEA] Save conversation from the window  (Read 1813 times)
fabioamd87
Hero Member
*****

l33tness: 0
Offline Offline

Posts: 428



View Profile Email
« on: September 11, 2008, 10:35:33 AM »

we should add a function that save the current conversation that we have with someoone directly from the window.

initially can be txt file... in the future other more complex format
Logged
checkm
Full Member
***

l33tness: 8
Offline Offline

Posts: 18


scacco_m@hotmail.it
View Profile WWW Email
« Reply #1 on: September 11, 2008, 01:24:19 PM »

Hi, I'm new in Emesene. I tried to code this feature only to understand the Emesene source.

Here it is:

Code:
--- emesene/Conversation.py     2008-09-11 23:16:07.000000000 +0000
+++ emesene-working/Conversation.py     2008-09-11 23:11:10.000000000 +0000
@@ -616,7 +616,13 @@
             print e

         self.ui.scrollToBottom()
-
+
+    def getConversationText(self):
+        start_iter = self.textBuffer.get_start_iter()
+        end_iter = self.textBuffer.get_end_iter()
+
+        return self.textBuffer.get_text(start_iter, end_iter)
+
     def getStatus(self):
         return self.switchboard.status

--- emesene/ConversationWindow.py       2008-09-11 23:16:07.000000000 +0000
+++ emesene-working/ConversationWindow.py       2008-09-11 23:05:14.000000000 +0000
@@ -495,7 +495,15 @@
         self.sendFileMenuItem.connect('activate', self.onSendFileActivate)
         self.sendFileMenuItem.add_accelerator('activate', accelGroup, ord('S'),
             gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
-
+
+        saveMenuItem = gtk.ImageMenuItem(_('Sa_ve Conversation...'))
+        saveMenuItem.set_image(gtk.image_new_from_stock(gtk.STOCK_SAVE,
+                                                        gtk.ICON_SIZE_MENU))
+        saveMenuItem.connect('activate', SaveConversationDialog,
+                             self.parentConversationWindow)
+        saveMenuItem.add_accelerator('activate', accelGroup, ord('V'),
+            gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
+
         clearMenuItem = gtk.ImageMenuItem(_('C_lear Conversation'))
         clearMenuItem.set_image(gtk.image_new_from_stock(gtk.STOCK_CLEAR,
                                     gtk.ICON_SIZE_MENU))
@@ -513,6 +521,7 @@

         conversationMenu.add(self.inviteMenuItem)
         conversationMenu.add(self.sendFileMenuItem)
+        conversationMenu.add(saveMenuItem)
         conversationMenu.add(clearMenuItem)
         conversationMenu.add(gtk.SeparatorMenuItem())
         conversationMenu.add(closeMenuItem)
@@ -544,7 +553,7 @@
     def onSendFileActivate(self, *args):
         '''This method is called when Invite is activated on the menu'''
         self.parentConversationWindow.send_file_dialog()
-
+
     def onLogActivate(self, check):
         '''This method is called when Log is activated on the menu'''
         self.parentConversationWindow.conversation.setDoLog(
@@ -562,3 +571,31 @@
         '''This method is called when a switchboard error is detected'''
         self.inviteMenuItem.set_sensitive(False)
         self.sendFileMenuItem.set_sensitive(False)
+
+class SaveConversationDialog (gtk.FileChooserDialog):
+    def __init__ (self, action, parentConversationWindow):
+        self.parentConversationWindow = parentConversationWindow
+
+        gtk.FileChooserDialog.__init__(self,
+                                       title="Save Conversation to a file",
+                                       parent=None,
+                                       action=gtk.FILE_CHOOSER_ACTION_SAVE,
+                                       buttons=(gtk.STOCK_SAVE, gtk.RESPONSE_OK,
+                                       gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT),
+                                       backend=None)
+
+        response = self.run()
+
+        if response == gtk.RESPONSE_OK:
+            self.filename = self.get_filename()
+            self.save()
+
+        self.destroy()
+
+    def save (self):
+        conversation = self.parentConversationWindow.conversation
+        text = conversation.getConversationText()
+
+        file = open(self.filename, 'w')
+        file.write(text)
+        file.close()
\ No newline at end of file

How can I avoid to show those special characters? Is there any other way to get the conversation text?

Sorry for ignorance. :-)
Logged

fabioamd87
Hero Member
*****

l33tness: 0
Offline Offline

Posts: 428



View Profile Email
« Reply #2 on: September 11, 2008, 01:31:49 PM »

wow really fast, but witch is the text format? html or txt?
anyway, tanks!
Logged
Respawner
Full Member
***

l33tness: 1
Offline Offline

Posts: 42


Ubuntu 9.04 user

respawneral@gmail.com
View Profile WWW Email
« Reply #3 on: September 11, 2008, 03:47:12 PM »

Looks to be written in plain text as the text is displayed in the conversation window.
Code:
def save (self):
        conversation = self.parentConversationWindow.conversation
        text = conversation.getConversationText()

        file = open(self.filename, 'w')
        file.write(text)
        file.close()
Thanks for code I'll try it.

Edit: Works for me, thanks again.
« Last Edit: September 11, 2008, 04:01:14 PM by Respawner » Logged
checkm
Full Member
***

l33tness: 8
Offline Offline

Posts: 18


scacco_m@hotmail.it
View Profile WWW Email
« Reply #4 on: September 12, 2008, 06:13:30 AM »

"Sa_ve Conversation" mnemonic accelerator is blocking Ctrl+V clipboard shortcut:

Here is the right one:
Code:
--- emesene/Conversation.py     2008-09-11 23:16:07.000000000 +0000
+++ emesene-working/Conversation.py     2008-09-11 23:11:10.000000000 +0000
@@ -616,7 +616,13 @@
             print e

         self.ui.scrollToBottom()
-
+
+    def getConversationText(self):
+        start_iter = self.textBuffer.get_start_iter()
+        end_iter = self.textBuffer.get_end_iter()
+
+        return self.textBuffer.get_text(start_iter, end_iter)
+
     def getStatus(self):
         return self.switchboard.status

--- emesene/ConversationWindow.py       2008-09-11 23:16:07.000000000 +0000
+++ emesene-working/ConversationWindow.py       2008-09-11 23:05:14.000000000 +0000
@@ -495,7 +495,15 @@
         self.sendFileMenuItem.connect('activate', self.onSendFileActivate)
         self.sendFileMenuItem.add_accelerator('activate', accelGroup, ord('S'),
             gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
-
+
+        saveMenuItem = gtk.ImageMenuItem(_('Save Conve_rsation...'))
+        saveMenuItem.set_image(gtk.image_new_from_stock(gtk.STOCK_SAVE,
+                                                        gtk.ICON_SIZE_MENU))
+        saveMenuItem.connect('activate', SaveConversationDialog,
+                             self.parentConversationWindow)
+        saveMenuItem.add_accelerator('activate', accelGroup, ord('R'),
+            gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
+
         clearMenuItem = gtk.ImageMenuItem(_('C_lear Conversation'))
         clearMenuItem.set_image(gtk.image_new_from_stock(gtk.STOCK_CLEAR,
                                     gtk.ICON_SIZE_MENU))
@@ -513,6 +521,7 @@

         conversationMenu.add(self.inviteMenuItem)
         conversationMenu.add(self.sendFileMenuItem)
+        conversationMenu.add(saveMenuItem)
         conversationMenu.add(clearMenuItem)
         conversationMenu.add(gtk.SeparatorMenuItem())
         conversationMenu.add(closeMenuItem)
@@ -544,7 +553,7 @@
     def onSendFileActivate(self, *args):
         '''This method is called when Invite is activated on the menu'''
         self.parentConversationWindow.send_file_dialog()
-
+
     def onLogActivate(self, check):
         '''This method is called when Log is activated on the menu'''
         self.parentConversationWindow.conversation.setDoLog(
@@ -562,3 +571,31 @@
         '''This method is called when a switchboard error is detected'''
         self.inviteMenuItem.set_sensitive(False)
         self.sendFileMenuItem.set_sensitive(False)
+
+class SaveConversationDialog (gtk.FileChooserDialog):
+    def __init__ (self, action, parentConversationWindow):
+        self.parentConversationWindow = parentConversationWindow
+
+        gtk.FileChooserDialog.__init__(self,
+                                       title="Save Conversation to a file",
+                                       parent=None,
+                                       action=gtk.FILE_CHOOSER_ACTION_SAVE,
+                                       buttons=(gtk.STOCK_SAVE, gtk.RESPONSE_OK,
+                                       gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT),
+                                       backend=None)
+
+        response = self.run()
+
+        if response == gtk.RESPONSE_OK:
+            self.filename = self.get_filename()
+            self.save()
+
+        self.destroy()
+
+    def save (self):
+        conversation = self.parentConversationWindow.conversation
+        text = conversation.getConversationText()
+
+        file = open(self.filename, 'w')
+        file.write(text)
+        file.close()
\ No newline at end of file
« Last Edit: September 14, 2008, 01:39:50 AM by checkm » Logged

boyska
Hero Member
*****

l33tness: 13
Offline Offline

Posts: 300


winston89@fastwebnet.it
View Profile
« Reply #5 on: September 12, 2008, 07:02:50 AM »

+1 for that. checkm, you're gonna be my new hero Wink
Logged
C10uD
ololol
Administrator
Hero Member
*****

l33tness: -9988
Offline Offline

Posts: 2145



View Profile Email
« Reply #6 on: September 13, 2008, 12:16:25 AM »

finally someone who doesn't make new bugs, right boyska? Cheesy
Logged
checkm
Full Member
***

l33tness: 8
Offline Offline

Posts: 18


scacco_m@hotmail.it
View Profile WWW Email
« Reply #7 on: September 13, 2008, 12:32:59 AM »

Oh, thanks for appreciation. Wink
Logged

fabioamd87
Hero Member
*****

l33tness: 0
Offline Offline

Posts: 428



View Profile Email
« Reply #8 on: January 06, 2010, 08:54:25 AM »

will this feature merged?
Logged
C10uD
ololol
Administrator
Hero Member
*****

l33tness: -9988
Offline Offline

Posts: 2145



View Profile Email
« Reply #9 on: January 07, 2010, 05:38:14 AM »

i didn't have commit access over _one year ago_ (!) but if this can be ported to current svn, (with removable button from preferences, etc.) i can apply it
Logged
fabioamd87
Hero Member
*****

l33tness: 0
Offline Offline

Posts: 428



View Profile Email
« Reply #10 on: January 07, 2010, 05:45:09 AM »

okk keep us updated!
Logged
C10uD
ololol
Administrator
Hero Member
*****

l33tness: -9988
Offline Offline

Posts: 2145



View Profile Email
« Reply #11 on: January 07, 2010, 07:36:54 AM »

my message was supposed to be read:

fix it, and send me the diff Smiley
Logged
checkm
Full Member
***

l33tness: 8
Offline Offline

Posts: 18


scacco_m@hotmail.it
View Profile WWW Email
« Reply #12 on: January 07, 2010, 12:29:41 PM »

Hi everybody! I'm back after a year of non-programming activity. What's up with that patch? What I have to change?

Tell me, I would be glad if it will be merged. Wink
Logged

C10uD
ololol
Administrator
Hero Member
*****

l33tness: -9988
Offline Offline

Posts: 2145



View Profile Email
« Reply #13 on: January 07, 2010, 12:53:37 PM »

it needs to be tested against latest svn, and add an option for removing that button from the toolbar like other buttons in preference windows...maybe a less invasive stuff like a plugin could be even better

greets
Logged
hit^
Hero Member
*****

l33tness: 1
Offline Offline

Posts: 336


svn up´d


View Profile
« Reply #14 on: January 08, 2010, 01:50:29 AM »

Code:
Index: PreferenceWindow.py
===================================================================
--- PreferenceWindow.py (revision 2175)
+++ PreferenceWindow.py (working copy)
@@ -1135,7 +1135,20 @@
         self.sendfileButton.connect('clicked', self.on_toggled, 'toolSendFile')
         self.pack_start(self.sendfileButton, False, False)
 
+        #save conversation
+        self.saveButton = gtk.ToggleButton()
+        saveIcon = self.controller.theme.getImage('save')
+        if saveIcon != None:
+            self.saveButton.set_image(gtk.image_new_from_pixbuf(saveIcon))
+        else:
+            self.saveButton.set_image(gtk.image_new_from_stock(gtk.STOCK_SAVE_AS,gtk.ICON_SIZE_SMALL_TOOLBAR))
+        self.saveButton.set_active(not self.config.user['toolSave'])
+        self.saveButton.set_tooltip_text(_('Save conversation'))
 
+        self.saveButton.connect('clicked', self.on_toggled, 'toolSave')
+        self.pack_start(self.saveButton, False, False)
+
+
         # webcam send hax
         camicon = gtk.image_new_from_pixbuf(self.controller.theme.getImage('cam'))
         self.sendWebcamButton = gtk.ToggleButton()
Index: Conversation.py
===================================================================
--- Conversation.py (revision 2175)
+++ Conversation.py (working copy)
@@ -713,6 +713,12 @@
         if self.switchboard and self.ui:
             self.ui.update_eventbox()
 
+    def getConversationText(self):
+        start_iter = self.textBuffer.get_start_iter()
+        end_iter = self.textBuffer.get_end_iter()
+
+        return self.textBuffer.get_text(start_iter, end_iter)
+
     def getStatus(self):
         return self.switchboard.status
 
Index: ConversationWindow.py
===================================================================
--- ConversationWindow.py (revision 2175)
+++ ConversationWindow.py (working copy)
@@ -100,6 +100,8 @@
                 gtk.ACCEL_LOCKED, self.menu.onInviteActivate)
             accelGroup.connect_group(ord('S'), gtk.gdk.CONTROL_MASK, \
                 gtk.ACCEL_LOCKED, self.menu.onSendFileActivate)
+            accelGroup.connect_group(ord('R'), gtk.gdk.CONTROL_MASK, \
+                gtk.ACCEL_LOCKED, self.menu.SaveConversationDialog)
 
         self.vbox.show()
 
@@ -158,6 +160,7 @@
             accelGroup.disconnect_key(ord('Q'), gtk.gdk.CONTROL_MASK)
             accelGroup.disconnect_key(ord('I'), gtk.gdk.CONTROL_MASK)
             accelGroup.disconnect_key(ord('S'), gtk.gdk.CONTROL_MASK)
+            accelGroup.disconnect_key(ord('R'), gtk.gdk.CONTROL_MASK)
             accelGroup.connect_group(ord('L'), gtk.gdk.CONTROL_MASK, \
                 gtk.ACCEL_LOCKED, self.clearOutputText)
             accelGroup.connect_group(ord('Q'), gtk.gdk.CONTROL_MASK, \
@@ -166,6 +169,8 @@
                 gtk.ACCEL_LOCKED, self.menu.onInviteActivate)
             accelGroup.connect_group(ord('S'), gtk.gdk.CONTROL_MASK, \
                 gtk.ACCEL_LOCKED, self.menu.onSendFileActivate)
+            accelGroup.connect_group(ord('R'), gtk.gdk.CONTROL_MASK, \
+                gtk.ACCEL_LOCKED, self.menu.SaveConversationDialog)
             self.menu.hide()
 
     def on_avatars_change(self, _config, value, oldValue):
@@ -600,6 +605,14 @@
         self.sendFileMenuItem.add_accelerator('activate', accelGroup, ord('S'),
             gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
 
+        saveMenuItem = gtk.ImageMenuItem(_('Save Conve_rsation...'))
+        saveMenuItem.set_image(gtk.image_new_from_stock(gtk.STOCK_SAVE,
+                                                        gtk.ICON_SIZE_MENU))
+        saveMenuItem.connect('activate', SaveConversationDialog,
+                             self.parentConversationWindow)
+        saveMenuItem.add_accelerator('activate', accelGroup, ord('R'),
+            gtk.gdk.CONTROL_MASK, gtk.ACCEL_VISIBLE)
+
         clearMenuItem = gtk.ImageMenuItem(_('C_lear Conversation'))
         clearMenuItem.set_image(gtk.image_new_from_stock(gtk.STOCK_CLEAR,
                                     gtk.ICON_SIZE_MENU))
@@ -617,6 +630,7 @@
 
         conversationMenu.add(self.inviteMenuItem)
         conversationMenu.add(self.sendFileMenuItem)
+        conversationMenu.add(saveMenuItem)
         conversationMenu.add(clearMenuItem)
         conversationMenu.add(gtk.SeparatorMenuItem())
         conversationMenu.add(closeMenuItem)
@@ -649,6 +663,10 @@
         '''This method is called when Invite is activated on the menu'''
         self.parentConversationWindow.send_file_dialog()
 
+    def onSaveActivate(self, *args):
+        '''This method is called when Invite is activated on the menu'''
+        self.parentConversationWindow.conversation.SaveConversationDialog()
+
     def onLogActivate(self, check):
         '''This method is called when Log is activated on the menu'''
         self.parentConversationWindow.conversation.setDoLog(
@@ -666,3 +684,31 @@
         '''This method is called when a switchboard error is detected'''
         self.inviteMenuItem.set_sensitive(False)
         self.sendFileMenuItem.set_sensitive(False)
+
+class SaveConversationDialog (gtk.FileChooserDialog):
+    def __init__ (self, action, parentConversationWindow):
+        self.parentConversationWindow = parentConversationWindow
+
+        gtk.FileChooserDialog.__init__(self,
+                                       title="Save Conversation to a file",
+                                       parent=None,
+                                       action=gtk.FILE_CHOOSER_ACTION_SAVE,
+                                       buttons=(gtk.STOCK_SAVE, gtk.RESPONSE_OK,
+                                       gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT),
+                                       backend=None)
+
+        response = self.run()
+
+        if response == gtk.RESPONSE_OK:
+            self.filename = self.get_filename()
+            self.save()
+
+        self.destroy()
+
+    def save (self):
+        conversation = self.parentConversationWindow.conversation
+        text = conversation.getConversationText()
+
+        file = open(self.filename, 'w')
+        file.write(text)
+        file.close()
Index: Config.py
===================================================================
--- Config.py (revision 2175)
+++ Config.py (working copy)
@@ -159,6 +159,7 @@
     'toolNudge' : True,
     'toolInvite' : True,
     'toolSendFile' : True,
+    'toolSave' : True,
     'toolWebcam' : True,
     'toolClear' : True,    
 }
Index: ConversationUI.py
===================================================================
--- ConversationUI.py (revision 2175)
+++ ConversationUI.py (working copy)
@@ -1523,10 +1523,27 @@
             self.sendfileButton.connect('clicked', self.sendFileClicked)
             self.insert(self.sendfileButton, -1)
             self.sendfileButton.set_tooltip_text(_('Send a file'))
-            separator = True
+            separator = False
         else:
             self.sendfileButton = None
 
+        #save conversation
+        if self.config.user['toolSave']:
+            self.saveButton = gtk.ToolButton()
+            self.saveButton.set_label(_('Save conversation'))
+            if self.controller.theme.getImage('save'):
+                saveicon = gtk.Image()
+                saveicon.set_from_pixbuf(self.controller.theme.getImage('save'))
+                self.saveButton.set_icon_widget(saveicon)
+            else:
+                self.saveButton.set_stock_id(gtk.STOCK_SAVE_AS)
+            self.saveButton.connect('clicked', self.showSaveDialog)
+            self.insert(self.saveButton, -1)
+            self.saveButton.set_tooltip_text(_('Save conversation'))
+            separator = True
+        else:
+            self.saveButton = None
+
         # webcam send hax
         if self.config.user['toolWebcam']:
             camicon = gtk.Image()
@@ -1667,6 +1684,10 @@
         if win is not None:
             win.send_file_dialog()
 
+    def showSaveDialog(self, *args):
+        '''this method is called when the user click the save conversation button'''
+        self.parentUI.parentConversation.parentConversationWindow.SaveConversationDialog()
+
     def sendWebcamClicked(self, *args):
         ret = self.parentUI.parentConversation.sendWebcam()
         if ret == 1:

Almost working with latest svn, along with prefferences' settings for buttons, but my knowledges end here Cheesy This should be very quick fix for someone who knows emesene better.

Traceback (most recent call last):

  File "/home/hit/Apps/emesene/ConversationUI.py", line 1689, in showSaveDialog
    self.parentUI.parentConversation.parentConversationWindow.SaveConversationDialog()

AttributeError: 'ConversationWindow' object has no attribute 'SaveConversationDialog'
Logged

"We are changing the world, one commit at a time."
Pages: [1] 2
  Print  
 
Jump to:  

TinyPortal v.1.0.6 beta 2 © Bloc
Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!