Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am creating a script in Python to integrate Pidgin with Unity (12.04), I've managed to do the counting notifications system using the Launcher API. But I dont know what event or signal is activated when the conversation window gains focus (To clear the message counter). I've tried some of the signals available on the documentation of Pidgin but none of them worked. Is there any GTK(or anything) event that is triggered when the window chat gets focus?

share|improve this question
    
Will you publish the script somewhere? :) –  wik Nov 1 '12 at 17:48
add comment

1 Answer

up vote 1 down vote accepted

Disclaimer: I haven't tested this method

I see you already cover the part regarding to the Launcher API, if not it's quite similar to what you already have done.

About Pidgin integration, looking into the API I've found that Pidgin notify via DBus of almost everything that happens with the client.

Looking carefully you can see there's a list of available signals. One of them is the conversation related ones. One of them is the conversation-updated signal. Detailed by:

Description: Emitted when a conversation is updated.

Parameters:

  • conv: The conversation that was updated.

  • type: The type of update that was made

Looking into the types of updates that can come with ths signal you find PURPLE_CONV_UPDATE_UNSEEN that is triggered when the unseen state is updated.

So, now all you have to do is to adapt your code to handle this signal.

Edit:

I've tested the method, and it works. In this pastebin is my example code if you want to take a look.

share|improve this answer
    
Hi, thanks for the reply. I made some tests, it seems this signal is activated when the chat window gets focus, but also when you receive a new message even if the chat window is not open, getting the signal 4 (along with the 11 "PURPLE_CONV_UPDATE_FEATURES") overriding the signal I use to update the counter ("ReceivedImMsg") so it turns out to clear the counter for unread messages instantly. –  Mr Alles Sep 25 '12 at 14:56
    
I managed to make the script work creating a condition which receive the signal 4 twice to perform the function of cleaning the counter, it works with the condition of clicking sometimes in the window ... Looking at the documentation for Pidgin again I noticed an interesting field called "has_focus" maybe I can use it? –  Mr Alles Sep 25 '12 at 17:04
    
Mmm ... as has_focus isn't a signal you can't read it from DBus. But you can check it every time the signals are triggered. It must work in that way. –  Ángel Araya Sep 25 '12 at 21:32
    
If you consider my answer to be correct, feel free to make it the correct answer by checking at the left top of the question. =) –  Ángel Araya Sep 25 '12 at 21:34
1  
You have to get the conversation (or window?) object from Pidgin via DBus, and then read the has_focus flag as you think its necesary. If you give some time maybe I can provide some code. –  Ángel Araya Sep 25 '12 at 21:41
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.