Skip to content

Commit

Permalink
[GTK] Allow zooming of contacts' display pictures when clicking them
Browse files Browse the repository at this point in the history
This is a collection of a few commits. See below.
[GTK] Allow zooming of contacts' display pictures when clicking them
[GTK] Remove jumping movement of nickname when zooming dp
[GTK] Added comment about 2 variables
[GTK] Fix some things
    * typingStopped()'s timer is not 6 sec. not 10
    * DP sizes used when zooming are now set in common.py
    * Fixed typo %s/comversation/conversation/g
  • Loading branch information
jonte committed Aug 12, 2009
1 parent 5461fbf commit ff55cd6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
26 changes: 21 additions & 5 deletions amsn2/gui/front_ends/gtk/chat_window.py
Expand Up @@ -34,6 +34,7 @@
import gobject
import os
from image import Image
import common

class aMSNChatWindow(base.aMSNChatWindow, gtk.Window):
def __init__(self, amsn_core):
Expand Down Expand Up @@ -354,7 +355,7 @@ def onMessageReceived(self, messageview, formatting=None):
def onUserJoined(self, contact):
print "%s joined the conversation" % (contact,)
self.__print_info("%s joined the conversation" % (contact,))
self.__set_statusbar_text("%s joined the comversation" % (contact,))
self.__set_statusbar_text("%s joined the conversation" % (contact,))

def onUserLeft(self, contact):
print "%s left the conversation" % (contact,)
Expand All @@ -363,7 +364,7 @@ def onUserLeft(self, contact):
self.__typingStopped()

def onUserTyping(self, contact):
""" Set a timer for 10 sec every time a user types. If the user
""" Set a timer for 6 sec every time a user types. If the user
continues typing during these 10 sec, kill the timer and start over with
10 sec. If the user stops typing; call __typingStopped """

Expand All @@ -372,7 +373,7 @@ def onUserTyping(self, contact):
if self.typingTimer != None:
gobject.source_remove(self.typingTimer)
self.typingTimer = None
self.typingTimer = gobject.timeout_add(10000, self.__typingStopped)
self.typingTimer = gobject.timeout_add(6000, self.__typingStopped)

def nudge(self):
self.__print_info('Nudge received')
Expand All @@ -388,14 +389,17 @@ def __init__(self, theme_manager, cviews=None):
self.title_color = gtk.gdk.color_parse('#dadada')
self.psm_color = '#999999'
self.theme_manager = theme_manager
self.cviews = cviews

self.title.set_use_markup(True)
self.title.set_justify(gtk.JUSTIFY_LEFT)
self.title.set_ellipsize(pango.ELLIPSIZE_END)
self.title.set_alignment(xalign=0, yalign=0.5)
self.title.set_padding(xpad=2, ypad=2)

self.dp.set_size_request(50,50)
# Load default dp's size from common
self.dp.set_size_request(common.DP_MINI[0],
common.DP_MINI[1])

hbox = gtk.HBox(False,0)
hbox.pack_start(self.buddy_icon, False,False,0)
Expand All @@ -405,6 +409,7 @@ def __init__(self, theme_manager, cviews=None):
self.modify_bg(gtk.STATE_NORMAL, self.title_color)
self.add(hbox)

self.connect("button-release-event", self.__dpClicked)
self.update(cviews)

def update(self, cviews):
Expand All @@ -419,7 +424,8 @@ def update(self, cviews):

#FIXME: Which user do we show in a multiconversation?
img = Image(self.theme_manager, cviews[0].dp)
self.dp.set_from_pixbuf(img.to_pixbuf(50,50))
size = self.dp.get_size_request()
self.dp.set_from_pixbuf(img.to_pixbuf(size[0],size[1]))

title = '<span size="large"><b>%s</b></span>' % (nickname, )
title += '<span size="medium"> %s</span>' % (status, )
Expand All @@ -430,3 +436,13 @@ def update(self, cviews):

self.title.set_markup(title)

def __dpClicked(self, source, event):
# Called when the display picture of the other person is clicked
if source.dp.get_size_request() == common.DP_MINI:
source.dp.set_size_request(common.DP_LARGE[0],common.DP_LARGE[1])
self.title.set_alignment(xalign = 0, yalign = 0.09)
else:
source.dp.set_size_request(common.DP_MINI[0],common.DP_MINI[1])
self.title.set_alignment(xalign = 0, yalign = 0.5)

self.update(self.cviews)
4 changes: 4 additions & 0 deletions amsn2/gui/front_ends/gtk/common.py
Expand Up @@ -7,6 +7,10 @@

GUI_FONT = pango.FontDescription('normal 8')

# Sizes of the contacts' display images in different states
DP_MINI = (50, 50)
DP_LARGE = (100, 100)

def stringvToHtml(stringv):
out = ''
for x in stringv._elements:
Expand Down

0 comments on commit ff55cd6

Please sign in to comment.