本文整理汇总了Python中utils.safe_gtk_pixbuf_load函数的典型用法代码示例。如果您正苦于以下问题:Python safe_gtk_pixbuf_load函数的具体用法?Python safe_gtk_pixbuf_load怎么用?Python safe_gtk_pixbuf_load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了safe_gtk_pixbuf_load函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _get_contact_pixbuf_or_default
def _get_contact_pixbuf_or_default(self, contact):
'''try to return a pixbuf of the user picture or the default
picture
'''
if contact.picture:
try:
animation = gtk.gdk.PixbufAnimation(contact.picture)
except gobject.GError:
pix = utils.safe_gtk_pixbuf_load(gui.theme.user,
(self.avatar_size, self.avatar_size))
picture = gtk.image_new_from_pixbuf(pix)
return picture
if animation.is_static_image():
pix = utils.safe_gtk_pixbuf_load(contact.picture,
(self.avatar_size, self.avatar_size))
picture = gtk.image_new_from_pixbuf(pix)
else:
picture = gtk.image_new_from_animation(animation)
else:
pix = utils.safe_gtk_pixbuf_load(gui.theme.user,
(self.avatar_size, self.avatar_size))
picture = gtk.image_new_from_pixbuf(pix)
return picture
开发者ID:yako83,项目名称:emesene,代码行数:26,代码来源:ContactList.py
示例2: __init__
def __init__(self, callback, avatar_path):
gtk.Alignment.__init__(self, xalign=0.5, yalign=0.5, xscale=1.0,
yscale=1.0)
self.callback = callback
#for reconnecting
self.reconnect_timer_id = None
if avatar_path == '':
self.avatar_path = gui.theme.logo
else:
self.avatar_path = avatar_path
th_pix = utils.safe_gtk_pixbuf_load(gui.theme.throbber, None,
animated=True)
self.throbber = gtk.image_new_from_animation(th_pix)
self.b_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
self.b_cancel.connect('clicked', self._on_cancel_clicked)
self.b_cancel.set_border_width(8)
self.label = gtk.Label()
self.label.set_markup('<b>Connecting...</b>')
self.label_timer = gtk.Label()
self.label_timer.set_markup('<b>Connection error!\n </b>')
self.img_account = gtk.Image()
self.img_account.set_from_pixbuf(utils.safe_gtk_pixbuf_load(self.avatar_path,(96,96)))
al_throbber = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.2,
yscale=0.2)
al_button_cancel = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.15)
al_label = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
yscale=0.0)
al_label_timer = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
yscale=0.0)
al_logo = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
yscale=0.0)
al_throbber.add(self.throbber)
al_button_cancel.add(self.b_cancel)
al_label.add(self.label)
al_label_timer.add(self.label_timer)
al_logo.add(self.img_account)
vbox = gtk.VBox()
vbox.pack_start(al_logo, True, False)
vbox.pack_start(al_label, True, False)
vbox.pack_start(al_label_timer, True, False)
vbox.pack_start(al_throbber, True, False)
vbox.pack_start(al_button_cancel, True, True)
self.add(vbox)
vbox.show_all()
self.dim = 96
gobject.timeout_add(20, self.do_animation)
self.label.hide()
self.throbber.hide()
self.label_timer.hide()
开发者ID:JPtja,项目名称:emesene,代码行数:60,代码来源:Login.py
示例3: _get_contact_pixbuf_or_default
def _get_contact_pixbuf_or_default(self, contact):
'''try to return a pixbuf of the user picture or the default
picture
'''
if contact.picture:
picture = utils.safe_gtk_pixbuf_load(contact.picture,
(self.avatar_size, self.avatar_size))
else:
picture = utils.safe_gtk_pixbuf_load(gui.theme.user,
(self.avatar_size, self.avatar_size))
return picture
开发者ID:nicolaide,项目名称:emesene,代码行数:12,代码来源:ContactList.py
示例4: add_new_avatar
def add_new_avatar(self, filename):
''' add a new picture from filename into the avatar cache '''
def gen_filename(source):
# generate a unique (?) filename for the new avatar in cache
# implemented as sha224 digest
infile = open(source, 'rb')
data = infile.read()
infile.close()
return hashlib.sha224(data).hexdigest()
fpath = os.path.join(self.get_avatars_dir(), gen_filename(filename))
try:
#FIXME temporaney hack for animations
animation = gtk.gdk.PixbufAnimation(filename)
if not animation.is_static_image():
self.session.set_picture(filename)
if os.path.exists(self.avatar_path):
os.remove(self.avatar_path)
shutil.copy(filename, self.avatar_path)
return None, fpath
else:
if not os.path.exists(self.get_avatars_dir()):
os.makedirs(self.get_avatars_dir())
# Save in 96x96
pix_96 = utils.safe_gtk_pixbuf_load(filename, (96, 96))
pix_96.save(fpath, 'png')
return pix_96, fpath
except OSError, error:
print error
return None, fpath
开发者ID:SWOriginal,项目名称:emesene,代码行数:32,代码来源:AvatarManager.py
示例5: update_contact
def update_contact(self, contact):
'''update the data of contact'''
try:
weight = int(self.session.config.d_weights.get(contact.account, 0))
except ValueError:
weight = 0
self.session.config.d_weights[contact.account] = weight
offline = contact.status == e3.status.OFFLINE
contact_data = (self._get_contact_pixbuf_or_default(contact),
contact, self.format_nick(contact), True,
utils.safe_gtk_pixbuf_load(gui.theme.status_icons[contact.status]),
weight, False, offline)
found = False
for row in self._model:
obj = row[1]
if type(obj) == e3.Group:
for contact_row in row.iterchildren():
con = contact_row[1]
if con.account == contact.account:
found = True
self._model[contact_row.iter] = contact_data
self.update_group(obj)
elif type(obj) == e3.Contact and obj.account == contact.account:
found = True
self._model[row.iter] = contact_data
开发者ID:yako83,项目名称:emesene,代码行数:29,代码来源:ContactList.py
示例6: service_add_cb
def service_add_cb(self, s_name, service_name):
'''Add a new service to the service combo'''
if not s_name is None:
image = utils.safe_gtk_pixbuf_load(s_name)
else:
image = None
self.session_combo.get_model().append([image, service_name])
开发者ID:tiancj,项目名称:emesene,代码行数:7,代码来源:Login.py
示例7: update_contact
def update_contact(self, contact):
'''update the data of contact'''
try:
weight = int(self.session.config.d_weights.get(contact.account, 0))
except ValueError:
weight = 0
self.session.config.d_weights[contact.account] = weight
offline = contact.status == e3.status.OFFLINE
online = not offline
contact_data = (self._get_contact_pixbuf_or_default(contact),
contact, self.format_nick(contact), True,
utils.safe_gtk_pixbuf_load(gui.theme.status_icons[contact.status]),
weight, False, offline)
found = False
group_found = None
for row in self._model:
obj = row[1]
if type(obj) == e3.Group:
for contact_row in row.iterchildren():
con = contact_row[1]
if con.account == contact.account:
found = True
group_found = obj
self._model[contact_row.iter] = contact_data
self.update_group(obj)
elif type(obj) == e3.Contact and obj.account == contact.account:
found = True
self._model[row.iter] = contact_data
# if we are in order by status, the contact was found and now is offline/online
# delete contact from offline/online group and add to the oposite.
if self.order_by_status and found:
# y todavia no estoy en el grupo.
if offline and group_found != self.offline_group:
self.remove_contact(contact, self.online_group)
self.add_contact(contact, self.offline_group)
if online and group_found != self.online_group:
self.remove_contact(contact, self.offline_group)
self.add_contact(contact, self.online_group)
if self.order_by_group and self.group_offline and found:
# y todavia no estoy en el grupo.
if offline and group_found != self.offline_group:
self.remove_contact(contact, group_found)
self.add_contact(contact, self.offline_group)
if online and group_found == self.offline_group:
self.remove_contact(contact, self.offline_group)
if len(contact.groups) == 0:
self.add_contact(contact)
else:
for group in contact.groups:
self.add_contact(contact, self.session.groups[group])
开发者ID:WayneSan,项目名称:emesene,代码行数:58,代码来源:ContactList.py
示例8: update_group
def update_group(self, members):
''' sets the contacts list instead of a contact's avatar '''
self._contact_list.set_model(None)
del self._model
self._model = gtk.ListStore(gtk.gdk.Pixbuf, object, str, gtk.gdk.Pixbuf)
self.members = members
for member in self.members:
contact = self.session.contacts.get(member)
picture = contact.picture or gui.theme.image_theme.user
contact_data = (utils.safe_gtk_pixbuf_load(picture,(15,15)),
contact, contact.nick, utils.safe_gtk_pixbuf_load(
gui.theme.image_theme.status_icons[contact.status],(15,15)))
self._model.append(contact_data)
self._contact_list.set_model(self._model)
self._contact_list.show_all()
self._first_alig.set(0.5,0.0,1.0,2.0)
self.first = self._contact_list
self.set_size_request(200,-1)
开发者ID:RazvanB,项目名称:emesene,代码行数:18,代码来源:ContactInfoList.py
示例9: add_contact
def add_contact(self, contact, group=None):
'''add a contact to the contact list, add it to the group if
group is not None'''
try:
weight = int(self.session.config.d_weights.get(contact.account, 0))
except ValueError:
weight = 0
self.session.config.d_weights[contact.account] = weight
contact_data = (self._get_contact_pixbuf_or_default(contact), contact,
self.format_nick(contact), True,
utils.safe_gtk_pixbuf_load(gui.theme.status_icons[contact.status]),
weight)
# if no group add it to the root, but check that it's not on a group
# or in the root already
if not group or self.order_by_status:
for row in self._model:
obj = row[1]
# check on group
if type(obj) == e3.Group:
for contact_row in row.iterchildren():
con = contact_row[1]
if con.account == contact.account:
return contact_row.iter
# check on the root
elif type(obj) == e3.Contact and obj.account == contact.account:
return row.iter
return self._model.append(None, contact_data)
for row in self._model:
obj = row[1]
if type(obj) == e3.Group and obj.name == group.name:
# if the contact is already on the group, then dont add it
for contact_row in row.iterchildren():
con = contact_row[1]
if con.account == contact.account:
return contact_row.iter
return_iter = self._model.append(row.iter, contact_data)
self.update_group(group)
# search the use on the root to remove it if it's there
# since we added him to a group
for irow in self._model:
iobj = irow[1]
if type(iobj) == e3.Contact and \
iobj.account == contact.account:
del self._model[irow.iter]
return return_iter
else:
self.add_group(group)
return self.add_contact(contact, group)
开发者ID:nicolaide,项目名称:emesene,代码行数:56,代码来源:ContactList.py
示例10: __init__
def __init__(self, callback, avatar_path):
gtk.Alignment.__init__(self, xalign=0.5, yalign=0.5, xscale=1.0,
yscale=1.0)
self.callback = callback
#for reconnecting
self.reconnect_timer_id = None
Avatar = extension.get_default('avatar')
th_pix = utils.safe_gtk_pixbuf_load(gui.theme.throbber, None,
animated=True)
self.throbber = gtk.image_new_from_animation(th_pix)
self.b_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
self.b_cancel.connect('clicked', self._on_cancel_clicked)
self.b_cancel.set_border_width(8)
self.label = gtk.Label()
self.label.set_markup('<b>Connecting...</b>')
self.label_timer = gtk.Label()
self.label_timer.set_markup('<b>Connection error!\n </b>')
self.avatar = Avatar(cellDimention=96)
self.avatar.set_from_file(avatar_path)
al_throbber = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.2,
yscale=0.2)
al_button_cancel = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.15)
al_label = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
yscale=0.0)
al_label_timer = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
yscale=0.0)
al_logo = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
yscale=0.0)
al_throbber.add(self.throbber)
al_button_cancel.add(self.b_cancel)
al_label.add(self.label)
al_label_timer.add(self.label_timer)
al_logo.add(self.avatar)
vbox = gtk.VBox()
vbox.pack_start(al_logo, True, False)
vbox.pack_start(al_label, True, False)
vbox.pack_start(al_label_timer, True, False)
vbox.pack_start(al_throbber, True, False)
vbox.pack_start(al_button_cancel, True, True)
self.add(vbox)
vbox.show_all()
self.label_timer.hide()
开发者ID:Maverick87Shaka,项目名称:emesene,代码行数:54,代码来源:Login.py
示例11: do_animation
def do_animation(self):
'''do the avatar's animation on login'''
if self.dim <= 128:
self.dim += 4
self.img_account.set_from_pixbuf(utils.safe_gtk_pixbuf_load(
self.avatar_path,(self.dim,self.dim)))
return True
else:
self.label.show()
self.clear_connect()
return False
开发者ID:JPtja,项目名称:emesene,代码行数:11,代码来源:Login.py
示例12: __init__
def __init__(self, callback):
gtk.Alignment.__init__(self, xalign=0.5, yalign=0.5, xscale=1.0,
yscale=1.0)
self.callback = callback
th_pix = utils.safe_gtk_pixbuf_load(gui.theme.throbber, None,
animated=True)
self.throbber = gtk.image_new_from_animation(th_pix)
self.b_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
self.b_cancel.connect('clicked', self._on_cancel_clicked)
self.b_cancel.set_border_width(8)
self.label = gtk.Label()
self.label.set_markup('<b>Connecting... </b>')
img_account = gtk.Image()
img_account.set_from_pixbuf(utils.safe_gtk_pixbuf_load(gui.theme.logo))
al_throbber = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.2,
yscale=0.2)
al_button_cancel = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.15)
al_label = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
yscale=0.0)
al_logo = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
yscale=0.0)
al_throbber.add(self.throbber)
al_button_cancel.add(self.b_cancel)
al_label.add(self.label)
al_logo.add(img_account)
vbox = gtk.VBox()
vbox.pack_start(al_logo, True, False)
vbox.pack_start(al_label, True, False)
vbox.pack_start(al_throbber, True, False)
vbox.pack_start(al_button_cancel, True, True)
self.add(vbox)
vbox.show_all()
开发者ID:DarKprince,项目名称:emesene2,代码行数:41,代码来源:Login.py
示例13: PyNotification
def PyNotification(title, text, picture_path=None, const=None,
callback=None, tooltip=None):
if const == 'message-im':
#In this case title is contact nick
if title is None:
title = ""
title = Plus.msnplus_strip(title)
notification = pynotify.Notification(title, text, picture_path)
notification.set_icon_from_pixbuf(utils.safe_gtk_pixbuf_load(picture_path, (96, 96)))
notification.set_hint_string("append", "allowed")
notification.show()
开发者ID:manuargue,项目名称:emesene,代码行数:12,代码来源:PyNotification.py
示例14: _clear_all
def _clear_all(self):
'''
clear all login fields and checkbox
'''
self.remember_account.set_active(False)
self.remember_account.set_sensitive(True)
self.remember_password.set_active(False)
self.remember_password.set_sensitive(True)
self.auto_login.set_active(False)
self.forget_me.set_child_visible(False)
self.btn_status.set_status(e3.status.ONLINE)
self.txt_password.set_text('')
self.txt_password.set_sensitive(True)
self.img_account.set_from_pixbuf(
utils.safe_gtk_pixbuf_load(gui.theme.logo))
开发者ID:JPtja,项目名称:emesene,代码行数:15,代码来源:Login.py
示例15: __init__
def __init__(self, main_window):
"""constructor"""
self.model = gtk.ListStore(gtk.gdk.Pixbuf, \
gobject.TYPE_INT, gobject.TYPE_STRING)
gtk.ComboBox.__init__(self, self.model)
self.main_window = main_window
self.status = None
status_pixbuf_cell = gtk.CellRendererPixbuf()
status_text_cell = gtk.CellRendererText()
self.pack_start(status_pixbuf_cell, False)
self.pack_start(status_text_cell, False)
status_pixbuf_cell.set_property('xalign', 0.0)
status_pixbuf_cell.set_property('xpad', 5)
status_text_cell.set_property('xalign', 0.0)
status_text_cell.set_property('xpad', 5)
status_text_cell.set_property('width', 158)
self.add_attribute(status_pixbuf_cell, 'pixbuf', 0)
self.add_attribute(status_text_cell, 'text', 2)
self.set_resize_mode(0)
self.set_wrap_width(1)
current_status = main_window.session.account.status
active = 0
count = 0
for stat in e3.status.ORDERED:
status_name = e3.status.STATUS[stat]
if stat == current_status:
active = count
pixbuf = utils.safe_gtk_pixbuf_load(gui.theme.status_icons[stat])
pixbuf.scale_simple(20, 20, gtk.gdk.INTERP_BILINEAR)
self.model.append([pixbuf, stat, status_name]) # re-gettext-it
count += 1
self.set_active(active)
self.connect('scroll-event', self.on_scroll_event)
self.connect('changed', self.on_status_changed)
main_window.session.signals.status_change_succeed.subscribe(
self.on_status_change_succeed)
开发者ID:DarKprince,项目名称:emesene2,代码行数:46,代码来源:StatusCombo.py
示例16: set_picture_cb
def set_picture_cb(response, filename):
'''callback for the avatar chooser'''
if response == gui.stock.ACCEPT:
if self.config_dir.base_dir.replace('@', '-at-') == \
os.path.dirname(os.path.dirname(filename)):
self.session.set_picture(filename)
os.remove(self.avatar_path)
shutil.copy2(filename, self.avatar_path)
return
#i save in 128*128 for the animation on connect..if somebody like it...:)
try:
pix_128 = utils.safe_gtk_pixbuf_load(filename, (128,128))
pix_128.save(path_dir + '_temp', 'png')
self.session.set_picture(path_dir + '_temp')
if os.path.exists(self.avatar_path):
os.remove(self.avatar_path)
pix_128.save(self.avatar_path, 'png')
except OSError as e:
print e
开发者ID:Mindflyer,项目名称:emesene,代码行数:19,代码来源:UserPanel.py
示例17: new_combo_session
def new_combo_session(self):
account = self.config.get_or_set('last_logged_account', '')
default_session = extension.get_default('session')
count = 0
session_found = False
self.session_name_to_index = {}
if account in self.accounts:
service = self.config.d_user_service.get(
account.rpartition('|')[0], 'msn')
else:
service = self.config.service
for ext_id, ext in extension.get_extensions('session').iteritems():
if default_session.NAME == ext.NAME:
default_session_index = count
for service_name, service_data in ext.SERVICES.iteritems():
if service == service_name:
index = count
session_found = True
try:
s_name = getattr(gui.theme.image_theme,
"service_" + service_name)
image = utils.safe_gtk_pixbuf_load(s_name)
except:
image = None
self.session_combo.get_model().append([image, service_name])
self.session_name_to_index[service_name] = count
count += 1
if session_found:
self.session_combo.set_active(index)
else:
self.session_combo.set_active(default_session_index)
self.session_combo.connect('changed', self._on_session_changed)
self._combo_session_list.append(self.session_combo)
开发者ID:sreekumar-kr,项目名称:emesene,代码行数:43,代码来源:Login.py
示例18: _create_indicator
def _create_indicator(self, subtype, sender, body,
extra_text = '', cid=None):
"""
This creates a new indicator item, called by on_message, online & offline.
"""
if indicate:
try:
# Ubuntu 9.10+
ind = indicate.Indicator()
except Exception:
# Ubuntu 9.04
ind = indicate.IndicatorMessage()
#Get user icon.
contact = self.handler.session.contacts.get(body)
pixbuf = utils.safe_gtk_pixbuf_load(contact.picture, (48, 48))
if pixbuf is not None:
ind.set_property_icon("icon", pixbuf)
ind.set_property("subtype", subtype)
ind.set_property("sender", sender + extra_text)
if cid is not None:
ind.set_property("body", str(cid))
else:
ind.set_property("body", body)
ind.set_property_time("time", time.time())
ind.set_property("draw-attention", "true")
ind.connect("user-display", self._display)
ind.show()
# Add indicator to the dictionary
if subtype == "im":
self.indicator_dict[ind] = cid
self.r_indicator_dict[cid] = ind
for old_cid in self.indicator_dict.values():
if old_cid not in self.handler.session.conversations.keys():
# workaround: kill the orphan indicator
ind = self.r_indicator_dict[old_cid]
del self.indicator_dict[ind]
del self.r_indicator_dict[old_cid]
else:
return
开发者ID:19MiRkO91,项目名称:emesene,代码行数:43,代码来源:MessagingMenu.py
示例19: new_combo_session
def new_combo_session(self, session_combo, on_session_changed):
account = self.config.get_or_set('last_logged_account', '')
default_session = extension.get_default('session')
count=0
session_found = False
name_to_ext = {}
if account in self.accounts:
service = self.config.d_user_service.get(account, 'msn')
else:
service = 'msn'
for ext_id, ext in extension.get_extensions('session').iteritems():
if default_session.NAME == ext.NAME:
default_session_index = count
for service_name, service_data in ext.SERVICES.iteritems():
if service == service_name:
index = count
session_found = True
try:
# ugly eval here, is there another way?
s_name = getattr(gui.theme, "service_" + service_name)
image = utils.safe_gtk_pixbuf_load(s_name)
except:
image = None
session_combo.get_model().append([image, service_name])
name_to_ext[service_name] = (ext_id, ext)
count += 1
if session_found:
session_combo.set_active(index)
else:
session_combo.set_active(default_session_index)
session_combo.connect('changed', on_session_changed, name_to_ext)
self.__combo_session_list.append(session_combo)
return name_to_ext
开发者ID:canyalkin,项目名称:emesene,代码行数:43,代码来源:Login.py
示例20: _update_fields
def _update_fields(self, account):
'''
update the different fields according to the account that is
on the account entry
'''
self._clear_all()
if account == '':
return
flag = False
if account in self.accounts:
attr = int(self.remembers[account])
self.remember_account.set_sensitive(False)
self.forget_me.set_child_visible(True)
self.btn_status.set_status(int(self.status[account]))
path = self.config_dir.join(account.replace('@','-at-'), 'avatars', 'last')
if self.config_dir.file_readable(path):
pix = utils.safe_gtk_pixbuf_load(path, (96,96))
self.img_account.set_from_pixbuf(pix)
if attr == 3:#autologin,password,account checked
self.auto_login.set_active(True)
flag = True
elif attr == 2:#password,account checked
self.remember_password.set_active(True)
flag = True
elif attr == 1:#only account checked
self.remember_account.set_active(True)
self.remember_password.set_sensitive(False)
else:#if i'm here i have an error
self.show_error(_(
'Error while reading user config'))
self._clear_all()
#for not repeating code
if flag:
passw = self.accounts[account]
self.txt_password.set_text(base64.b64decode(passw))
self.txt_password.set_sensitive(False)
开发者ID:JPtja,项目名称:emesene,代码行数:41,代码来源:Login.py
注:本文中的utils.safe_gtk_pixbuf_load函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论