2005-12-28 00:55:34 +01:00
|
|
|
## message_window.py
|
|
|
|
##
|
|
|
|
## Copyright (C) 2005-2006 Travis Shirk <travis@pobox.com>
|
|
|
|
##
|
|
|
|
## This program is free software; you can redistribute it and/or modify
|
|
|
|
## it under the terms of the GNU General Public License as published
|
|
|
|
## by the Free Software Foundation; version 2 only.
|
|
|
|
##
|
|
|
|
## This program is distributed in the hope that it will be useful,
|
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
|
|
|
|
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
|
|
|
import pango
|
|
|
|
import gobject
|
|
|
|
|
2005-12-29 04:20:06 +01:00
|
|
|
import common
|
2005-12-31 07:27:22 +01:00
|
|
|
import gtkgui_helpers
|
|
|
|
|
2005-12-28 00:55:34 +01:00
|
|
|
from common import gajim
|
|
|
|
|
|
|
|
####################
|
|
|
|
# FIXME: Can't this stuff happen once?
|
|
|
|
from common import i18n
|
|
|
|
_ = i18n._
|
|
|
|
APP = i18n.APP
|
|
|
|
|
|
|
|
GTKGUI_GLADE = 'gtkgui.glade'
|
|
|
|
####################
|
|
|
|
|
|
|
|
class MessageWindow:
|
|
|
|
'''Class for windows which contain message like things; chats,
|
|
|
|
groupchats, etc.'''
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self._controls = {}
|
|
|
|
|
|
|
|
self.widget_name = 'message_window'
|
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, self.widget_name, APP)
|
|
|
|
self.window = self.xml.get_widget(self.widget_name)
|
|
|
|
self.alignment = self.xml.get_widget('alignment')
|
|
|
|
self.notebook = self.xml.get_widget('notebook')
|
|
|
|
|
2005-12-29 04:20:06 +01:00
|
|
|
# Remove the glade pages
|
|
|
|
while self.notebook.get_n_pages():
|
|
|
|
self.notebook.remove_page(0)
|
|
|
|
# Tab customizations
|
|
|
|
pref_pos = gajim.config.get('tabs_position')
|
|
|
|
if pref_pos != 'top':
|
|
|
|
if pref_pos == 'bottom':
|
|
|
|
nb_pos = gtk.POS_BOTTOM
|
|
|
|
elif pref_pos == 'left':
|
|
|
|
nb_pos = gtk.POS_LEFT
|
|
|
|
elif pref_pos == 'right':
|
|
|
|
nb_pos = gtk.POS_RIGHT
|
|
|
|
else:
|
|
|
|
nb_pos = gtk.POS_TOP
|
|
|
|
else:
|
|
|
|
nb_pos = gtk.POS_TOP
|
|
|
|
self.notebook.set_tab_pos(nb_pos)
|
|
|
|
if gajim.config.get('tabs_always_visible'):
|
|
|
|
self.notebook.set_show_tabs(True)
|
|
|
|
self.alignment.set_property('top-padding', 2)
|
|
|
|
else:
|
|
|
|
self.notebook.set_show_tabs(False)
|
|
|
|
self.notebook.set_show_border(gajim.config.get('tabs_border'))
|
|
|
|
|
2005-12-30 21:47:59 +01:00
|
|
|
# Connect event handling for this Window
|
|
|
|
self.window.connect('delete-event', self._on_window_delete)
|
|
|
|
self.window.connect('destroy', self._on_window_destroy)
|
2005-12-31 07:27:22 +01:00
|
|
|
|
|
|
|
# Restore previous window position
|
|
|
|
if gajim.config.get('saveposition'):
|
|
|
|
# get window position and size from config
|
|
|
|
gtkgui_helpers.move_window(self.window,
|
|
|
|
gajim.config.get('msgwin-x-position'),
|
|
|
|
gajim.config.get('msgwin-y-position'))
|
|
|
|
gtkgui_helpers.resize_window(self.window,
|
|
|
|
gajim.config.get('msgwin-width'),
|
|
|
|
gajim.config.get('msgwin-height'))
|
2005-12-30 21:47:59 +01:00
|
|
|
|
2005-12-29 04:20:06 +01:00
|
|
|
self.window.show_all()
|
|
|
|
|
2005-12-30 21:47:59 +01:00
|
|
|
def _on_window_delete(self, win, event):
|
|
|
|
print "MessageWindow._on_window_delete:", win, event
|
2005-12-31 07:27:22 +01:00
|
|
|
if gajim.config.get('saveposition'):
|
|
|
|
# save the window size and position
|
|
|
|
x, y = win.get_position()
|
|
|
|
gajim.config.set('msgwin-x-position', x)
|
|
|
|
gajim.config.set('msgwin-y-position', y)
|
|
|
|
width, height = win.get_size()
|
|
|
|
gajim.config.set('msgwin-width', width)
|
|
|
|
gajim.config.set('msgwin-height', height)
|
|
|
|
|
|
|
|
return False
|
2005-12-30 21:47:59 +01:00
|
|
|
def _on_window_destroy(self, win):
|
|
|
|
print "MessageWindow._on_window_destroy:", win
|
|
|
|
|
|
|
|
def new_tab(self, control):
|
|
|
|
assert(not self._controls.has_key(control.contact.jid))
|
|
|
|
self._controls[control.contact.jid] = control
|
|
|
|
|
2005-12-31 01:50:33 +01:00
|
|
|
control.widget.connect('key_press_event',
|
|
|
|
self.on_conversation_textview_key_press_event)
|
|
|
|
# FIXME: need to get this event without access to message_textvier
|
|
|
|
#control.widget.connect('mykeypress',
|
|
|
|
# self.on_message_textview_mykeypress_event)
|
|
|
|
control.widget.connect('key_press_event',
|
|
|
|
self.on_message_textview_key_press_event)
|
|
|
|
|
2005-12-30 21:47:59 +01:00
|
|
|
# Add notebook page and connect up to the tab's close button
|
|
|
|
xml = gtk.glade.XML(GTKGUI_GLADE, 'chat_tab_ebox', APP)
|
|
|
|
tab_label_box = xml.get_widget('chat_tab_ebox')
|
|
|
|
xml.signal_connect('on_close_button_clicked', self.on_close_button_clicked,
|
|
|
|
control.contact)
|
|
|
|
self.notebook.append_page(control.widget, tab_label_box)
|
|
|
|
|
2005-12-31 01:50:33 +01:00
|
|
|
self.redraw_tab(control.contact)
|
2005-12-31 07:27:22 +01:00
|
|
|
self.show_title()
|
2005-12-30 21:47:59 +01:00
|
|
|
self.window.show_all()
|
2005-12-31 01:50:33 +01:00
|
|
|
|
|
|
|
def on_message_textview_mykeypress_event(self, widget, event_keyval,
|
|
|
|
event_keymod):
|
|
|
|
# FIXME: Not called yet
|
|
|
|
print "MessageWindow.on_message_textview_mykeypress_event:", event
|
|
|
|
# NOTE: handles mykeypress which is custom signal; see message_textview.py
|
|
|
|
|
|
|
|
# construct event instance from binding
|
|
|
|
event = gtk.gdk.Event(gtk.gdk.KEY_PRESS) # it's always a key-press here
|
|
|
|
event.keyval = event_keyval
|
|
|
|
event.state = event_keymod
|
|
|
|
event.time = 0 # assign current time
|
|
|
|
|
|
|
|
if event.keyval == gtk.keysyms.ISO_Left_Tab: # SHIFT + TAB
|
|
|
|
if event.state & gtk.gdk.CONTROL_MASK: # CTRL + SHIFT + TAB
|
|
|
|
self.notebook.emit('key_press_event', event)
|
|
|
|
if event.keyval == gtk.keysyms.Tab:
|
|
|
|
if event.state & gtk.gdk.CONTROL_MASK: # CTRL + TAB
|
|
|
|
self.notebook.emit('key_press_event', event)
|
|
|
|
|
|
|
|
def on_message_textview_key_press_event(self, widget, event):
|
|
|
|
print "MessageWindow.on_message_textview_key_press_event:", event
|
|
|
|
if event.keyval == gtk.keysyms.Page_Down: # PAGE DOWN
|
|
|
|
if event.state & gtk.gdk.CONTROL_MASK: # CTRL + PAGE DOWN
|
|
|
|
self.notebook.emit('key_press_event', event)
|
|
|
|
elif event.keyval == gtk.keysyms.Page_Up: # PAGE UP
|
|
|
|
if event.state & gtk.gdk.CONTROL_MASK: # CTRL + PAGE UP
|
|
|
|
self.notebook.emit('key_press_event', event)
|
|
|
|
|
|
|
|
def on_conversation_textview_key_press_event(self, widget, event):
|
|
|
|
'''Do not block these events and send them to the notebook'''
|
|
|
|
print "MessageWindow.on_conversation_textview_key_press_event:", event
|
|
|
|
if event.state & gtk.gdk.CONTROL_MASK:
|
|
|
|
if event.keyval == gtk.keysyms.Tab: # CTRL + TAB
|
|
|
|
self.notebook.emit('key_press_event', event)
|
|
|
|
elif event.keyval == gtk.keysyms.ISO_Left_Tab: # CTRL + SHIFT + TAB
|
|
|
|
self.notebook.emit('key_press_event', event)
|
|
|
|
elif event.keyval == gtk.keysyms.Page_Down: # CTRL + PAGE DOWN
|
|
|
|
self.notebook.emit('key_press_event', event)
|
|
|
|
elif event.keyval == gtk.keysyms.Page_Up: # CTRL + PAGE UP
|
|
|
|
self.notebook.emit('key_press_event', event)
|
|
|
|
|
2005-12-30 21:47:59 +01:00
|
|
|
def on_close_button_clicked(self, button, contact):
|
|
|
|
'''When close button is pressed: close a tab'''
|
|
|
|
self.remove_tab(contact)
|
2005-12-31 07:27:22 +01:00
|
|
|
|
|
|
|
def show_title(self, urgent = True):
|
|
|
|
'''redraw the window's title'''
|
|
|
|
unread = 0
|
|
|
|
for ctl in self._controls.values():
|
|
|
|
unread += ctl.nb_unread
|
|
|
|
start = ''
|
|
|
|
if unread > 1:
|
|
|
|
start = '[' + unicode(unread) + '] '
|
|
|
|
elif unread == 1:
|
|
|
|
start = '* '
|
|
|
|
|
|
|
|
ctl = self.get_active_control()
|
|
|
|
if len(self._controls) > 1: # if more than one tab in the same window
|
|
|
|
add = ctl.display_name
|
|
|
|
elif len(self._controls) == 1: # just one tab
|
|
|
|
add = ctl.contact.name
|
|
|
|
# FIXME: This is for GC only
|
|
|
|
# elif self.widget_name == 'groupchat_window':
|
|
|
|
# name = gajim.get_nick_from_jid(jid)
|
|
|
|
# add = name
|
|
|
|
|
|
|
|
title = start + add
|
|
|
|
if len(gajim.connections) >= 2: # if we have 2 or more accounts
|
|
|
|
title += ' (' + _('account: ') + ctl.account + ')'
|
|
|
|
|
|
|
|
# Update UI
|
|
|
|
self.window.set_title(title)
|
|
|
|
if urgent:
|
|
|
|
gtkgui_helpers.set_unset_urgency_hint(self.window, unread)
|
2005-12-31 18:00:04 +01:00
|
|
|
|
|
|
|
def set_active_tab(self, jid):
|
|
|
|
ctl = self._controls[jid]
|
|
|
|
ctl_page = self.notebook.page_num(ctl.widget)
|
|
|
|
self.notebook.set_current_page(ctl_page)
|
2005-12-30 21:47:59 +01:00
|
|
|
|
|
|
|
def remove_tab(self, contact):
|
|
|
|
print "MessageWindow.remove_tab"
|
2005-12-31 18:00:04 +01:00
|
|
|
if len(self._controls) == 1:
|
|
|
|
# There is only one tab
|
|
|
|
# FIXME: Should we assert on contact?
|
|
|
|
self.window.destroy()
|
|
|
|
else:
|
|
|
|
pass
|
|
|
|
# TODO
|
2005-12-30 21:47:59 +01:00
|
|
|
|
2005-12-31 08:19:43 +01:00
|
|
|
def redraw_tab(self, contact, chatstate = None):
|
2005-12-31 01:50:33 +01:00
|
|
|
ctl = self._controls[contact.jid]
|
|
|
|
ctl.update_state()
|
|
|
|
|
|
|
|
hbox = self.notebook.get_tab_label(ctl.widget).get_children()[0]
|
|
|
|
status_img = hbox.get_children()[0]
|
|
|
|
nick_label = hbox.get_children()[1]
|
|
|
|
|
|
|
|
# Optionally hide close button
|
|
|
|
close_button = hbox.get_children()[2]
|
|
|
|
if gajim.config.get('tabs_close_button'):
|
|
|
|
close_button.show()
|
|
|
|
else:
|
|
|
|
close_button.hide()
|
|
|
|
|
|
|
|
# Update nick
|
2005-12-31 08:19:43 +01:00
|
|
|
nick_label.set_max_width_chars(10)
|
|
|
|
(tab_label_str, tab_label_color) = ctl.markup_tab_label(contact.name,
|
|
|
|
chatstate)
|
2005-12-31 07:27:22 +01:00
|
|
|
nick_label.set_markup(tab_label_str)
|
|
|
|
if tab_label_color:
|
|
|
|
nick_label.modify_fg(gtk.STATE_NORMAL, tab_label_color)
|
|
|
|
nick_label.modify_fg(gtk.STATE_ACTIVE, tab_label_color)
|
|
|
|
|
|
|
|
num_unread = ctl.nb_unread
|
2005-12-31 01:50:33 +01:00
|
|
|
# Set tab image (always 16x16); unread messages show the 'message' image
|
|
|
|
img_16 = gajim.interface.roster.get_appropriate_state_images(contact.jid)
|
|
|
|
if num_unread and gajim.config.get('show_unread_tab_icon'):
|
|
|
|
tab_img = img_16['message']
|
|
|
|
else:
|
|
|
|
tab_img = img_16[contact.show]
|
|
|
|
if tab_img.get_storage_type() == gtk.IMAGE_ANIMATION:
|
|
|
|
status_img.set_from_animation(tab_img.get_animation())
|
|
|
|
else:
|
|
|
|
status_img.set_from_pixbuf(tab_img.get_pixbuf())
|
|
|
|
|
|
|
|
def repaint_themed_widgets(self):
|
|
|
|
'''Repaint controls in the window with theme color'''
|
|
|
|
# iterate through controls and repaint
|
|
|
|
for ctl in self._controls.values():
|
|
|
|
ctl.repaint_themed_widgets()
|
2005-12-28 00:55:34 +01:00
|
|
|
|
2005-12-31 04:53:48 +01:00
|
|
|
def _widgetToControl(self, widget):
|
|
|
|
for ctl in self._controls.values():
|
|
|
|
if ctl.widget == widget:
|
|
|
|
return ctl
|
|
|
|
return None
|
|
|
|
|
2005-12-31 07:27:22 +01:00
|
|
|
def get_active_control(self):
|
2005-12-31 04:53:48 +01:00
|
|
|
notebook = self.notebook
|
|
|
|
active_widget = notebook.get_nth_page(notebook.get_current_page())
|
2005-12-31 07:27:22 +01:00
|
|
|
return self._widgetToControl(active_widget)
|
|
|
|
def get_active_contact(self):
|
|
|
|
return self.get_active_control().contact
|
2005-12-31 04:53:48 +01:00
|
|
|
def get_active_jid(self):
|
|
|
|
return self.get_active_contact().jid
|
|
|
|
|
|
|
|
def is_active(self):
|
|
|
|
return self.window.is_active()
|
2005-12-31 05:53:14 +01:00
|
|
|
def get_origin(self):
|
|
|
|
return self.window.window.get_origin()
|
2005-12-31 04:53:48 +01:00
|
|
|
|
2005-12-31 05:53:14 +01:00
|
|
|
def toggle_emoticons(self):
|
|
|
|
for ctl in self._controls.values():
|
|
|
|
ctl.toggle_emoticons()
|
2005-12-31 07:27:22 +01:00
|
|
|
def update_font(self):
|
|
|
|
for ctl in self._controls.values():
|
|
|
|
ctl.update_font()
|
|
|
|
def update_tags(self):
|
|
|
|
for ctl in self._controls.values():
|
|
|
|
ctl.update_tags()
|
2005-12-31 04:53:48 +01:00
|
|
|
|
2005-12-31 18:00:04 +01:00
|
|
|
def get_control_from_jid(self, jid):
|
|
|
|
for ctl in self._controls.values():
|
|
|
|
if ctl.contact.jid == jid:
|
|
|
|
return ctl
|
|
|
|
return None
|
|
|
|
|
2005-12-31 22:55:44 +01:00
|
|
|
def controls(self):
|
|
|
|
for ctl in self._controls.values():
|
|
|
|
yield ctl
|
|
|
|
|
|
|
|
def update_print_time(self):
|
|
|
|
if gajim.config.get('print_time') != 'sometimes':
|
|
|
|
for ctl in self.controls():
|
|
|
|
if ctl.print_time_timeout_id:
|
|
|
|
gobject.source_remove(ctl.print_time_timeout_id)
|
|
|
|
del ctl.print_time_timeout_id
|
|
|
|
else:
|
|
|
|
for ctl in self.controls():
|
|
|
|
if not ctl.print_time_timeout_id:
|
|
|
|
ctl.print_time_timeout()
|
|
|
|
ctl.print_time_timeout_id = gobject.timeout_add(300000,
|
|
|
|
ctl.print_time_timeout, None)
|
|
|
|
|
|
|
|
|
2005-12-28 00:55:34 +01:00
|
|
|
class MessageWindowMgr:
|
|
|
|
'''A manager and factory for MessageWindow objects'''
|
|
|
|
|
2005-12-29 04:20:06 +01:00
|
|
|
# These constants map to common.config.opt_one_window_types indices
|
|
|
|
CONFIG_NEVER = 0
|
|
|
|
CONFIG_ALWAYS = 1
|
|
|
|
CONFIG_PERACCT = 2
|
|
|
|
CONFIG_PERTYPE = 3
|
|
|
|
# A key constant for the main window for all messages
|
|
|
|
MAIN_WIN = 'main'
|
|
|
|
|
2005-12-28 00:55:34 +01:00
|
|
|
def __init__(self):
|
2005-12-29 04:20:06 +01:00
|
|
|
''' A dictionary of windows; the key depends on the config:
|
|
|
|
CONFIG_NEVER: The key is the contact JID
|
|
|
|
CONFIG_ALWAYS: The key is MessageWindowMgr.MAIN_WIN
|
|
|
|
CONFIG_PERACCT: The key is the account name
|
|
|
|
CONFIG_PERTYPE: The key is a message type constant'''
|
2005-12-31 22:55:44 +01:00
|
|
|
self._windows = {}
|
2005-12-29 04:20:06 +01:00
|
|
|
# Map the mode to a int constant for frequent compares
|
|
|
|
mode = gajim.config.get('one_message_window')
|
|
|
|
self.mode = common.config.opt_one_window_types.index(mode)
|
|
|
|
assert(self.mode != -1)
|
|
|
|
|
|
|
|
def _new_window(self):
|
|
|
|
win = MessageWindow()
|
|
|
|
# we track the lifetime of this window
|
|
|
|
win.window.connect('delete-event', self._on_window_delete)
|
|
|
|
win.window.connect('destroy', self._on_window_destroy)
|
|
|
|
return win
|
|
|
|
|
|
|
|
def _gtkWinToMsgWin(self, gtk_win):
|
2005-12-31 22:55:44 +01:00
|
|
|
for w in self._windows.values():
|
2005-12-31 01:50:33 +01:00
|
|
|
if w.window == gtk_win:
|
2005-12-29 04:20:06 +01:00
|
|
|
return w
|
|
|
|
return None
|
|
|
|
|
|
|
|
def _on_window_delete(self, win, event):
|
|
|
|
# FIXME
|
|
|
|
print "MessageWindowMgr._on_window_delete:", win
|
|
|
|
def _on_window_destroy(self, win):
|
|
|
|
# FIXME
|
|
|
|
print "MessageWindowMgr._on_window_destroy:", win
|
2005-12-31 01:50:33 +01:00
|
|
|
# TODO: Clean up windows
|
2005-12-29 04:20:06 +01:00
|
|
|
|
2005-12-31 18:00:04 +01:00
|
|
|
def get_window(self, jid):
|
2005-12-31 22:55:44 +01:00
|
|
|
for win in self._windows.values():
|
2005-12-31 18:00:04 +01:00
|
|
|
if win.get_control_from_jid(jid):
|
|
|
|
return win
|
|
|
|
return None
|
|
|
|
def has_window(self, jid):
|
|
|
|
return self.get_window(jid)
|
|
|
|
|
|
|
|
def create_window(self, contact, acct, type):
|
2005-12-29 04:20:06 +01:00
|
|
|
key = None
|
|
|
|
if self.mode == self.CONFIG_NEVER:
|
|
|
|
key = contact.jid
|
|
|
|
elif self.mode == self.CONFIG_ALWAYS:
|
|
|
|
key = self.MAIN_WIN
|
|
|
|
elif self.mode == self.CONFIG_PERACCT:
|
|
|
|
key = acct
|
|
|
|
elif self.mode == self.CONFIG_PERTYPE:
|
|
|
|
key = type
|
|
|
|
|
|
|
|
win = None
|
|
|
|
try:
|
2005-12-31 22:55:44 +01:00
|
|
|
win = self._windows[key]
|
2005-12-29 04:20:06 +01:00
|
|
|
except KeyError:
|
|
|
|
# FIXME
|
|
|
|
print "Creating tabbed chat window for '%s'" % str(key)
|
|
|
|
win = self._new_window()
|
2005-12-31 22:55:44 +01:00
|
|
|
self._windows[key] = win
|
2005-12-31 18:00:04 +01:00
|
|
|
|
2005-12-29 04:20:06 +01:00
|
|
|
assert(win)
|
|
|
|
return win
|
|
|
|
|
2005-12-31 22:55:44 +01:00
|
|
|
def get_control(self, jid):
|
|
|
|
win = self.get_window(jid)
|
|
|
|
if win:
|
|
|
|
return win.get_control_from_jid(jid)
|
|
|
|
return None
|
|
|
|
|
|
|
|
def windows(self):
|
|
|
|
for w in self._windows.values():
|
|
|
|
yield w
|
|
|
|
def controls(self):
|
|
|
|
for w in self._windows:
|
|
|
|
for c in w.controls():
|
|
|
|
yield c
|
|
|
|
|
2005-12-29 04:20:06 +01:00
|
|
|
class MessageControl(gtk.VBox):
|
|
|
|
'''An abstract base widget that can embed in the gtk.Notebook of a MessageWindow'''
|
|
|
|
|
2005-12-31 08:35:14 +01:00
|
|
|
def __init__(self, type_id, parent_win, widget_name, display_name, contact, account):
|
2005-12-29 04:20:06 +01:00
|
|
|
gtk.VBox.__init__(self)
|
2005-12-28 00:55:34 +01:00
|
|
|
|
2005-12-31 08:35:14 +01:00
|
|
|
self.type_id = type_id
|
2005-12-31 04:53:48 +01:00
|
|
|
self.parent_win = parent_win
|
2005-12-30 21:47:59 +01:00
|
|
|
self.widget_name = widget_name
|
2005-12-31 07:27:22 +01:00
|
|
|
self.display_name = display_name
|
2005-12-29 04:20:06 +01:00
|
|
|
self.contact = contact
|
2005-12-31 04:53:48 +01:00
|
|
|
self.account = account
|
2005-12-31 08:19:43 +01:00
|
|
|
self.compact_view_always = False
|
|
|
|
self.compact_view_current = False
|
2005-12-31 07:27:22 +01:00
|
|
|
self.nb_unread = 0
|
2005-12-31 22:55:44 +01:00
|
|
|
self.print_time_timeout_id = None
|
2005-12-29 04:49:57 +01:00
|
|
|
|
2005-12-29 04:20:06 +01:00
|
|
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, widget_name, APP)
|
|
|
|
self.widget = self.xml.get_widget(widget_name)
|
2005-12-31 05:53:14 +01:00
|
|
|
# Autoconnect glade signals
|
|
|
|
self.xml.signal_autoconnect(self)
|
2005-12-29 04:49:57 +01:00
|
|
|
|
|
|
|
def draw_widgets(self):
|
2005-12-31 01:50:33 +01:00
|
|
|
pass # NOTE: Derived classes should implement this
|
|
|
|
def repaint_themed_widgets(self, theme):
|
|
|
|
pass # NOTE: Derived classes SHOULD implement this
|
|
|
|
def update_state(self):
|
|
|
|
pass # NOTE: Derived classes SHOULD implement this
|
2005-12-31 05:53:14 +01:00
|
|
|
def toggle_emoticons(self):
|
|
|
|
pass # NOTE: Derived classes MAY implement this
|
2005-12-31 07:27:22 +01:00
|
|
|
def update_font(self):
|
|
|
|
pass # NOTE: Derived classes SHOULD implement this
|
|
|
|
def update_tags(self):
|
|
|
|
pass # NOTE: Derived classes SHOULD implement this
|
2005-12-31 22:55:44 +01:00
|
|
|
def print_time_timeout(self, arg):
|
|
|
|
# NOTE: Derived classes SHOULD implement this
|
|
|
|
if self.print_time_timeout_id:
|
|
|
|
gobject.source_remove(self.print_time_timeout_id)
|
|
|
|
del self.print_time_timeout_id
|
|
|
|
return False
|
2005-12-31 08:19:43 +01:00
|
|
|
def markup_tab_label(self, label_str, chatstate):
|
|
|
|
# NOTE: Derived classes SHOULD implement this
|
|
|
|
# Reurn a markup'd label and optional gtk.Color
|
|
|
|
return (label_str, None)
|
|
|
|
def prepare_context_menu(self):
|
|
|
|
# NOTE: Derived classes SHOULD implement this
|
|
|
|
return None
|
|
|
|
def set_compact_view(self, state):
|
|
|
|
self.compact_view_current = state
|
2005-12-31 04:53:48 +01:00
|
|
|
|
2005-12-31 09:13:20 +01:00
|
|
|
def send_message(self, message, keyID = '', type = 'chat', chatstate = None):
|
2005-12-31 04:53:48 +01:00
|
|
|
'''Send the given message to the active tab'''
|
|
|
|
# refresh timers
|
|
|
|
self.reset_kbd_mouse_timeout_vars()
|
|
|
|
|
|
|
|
jid = self.contact.jid
|
|
|
|
# Send and update history
|
2005-12-31 09:13:20 +01:00
|
|
|
gajim.connections[self.account].send_message(jid, message, keyID,
|
|
|
|
type = type, chatstate = chatstate)
|
2005-12-31 04:53:48 +01:00
|
|
|
|
2005-12-31 05:53:14 +01:00
|
|
|
def position_menu_under_button(self, menu):
|
|
|
|
#FIXME: BUG http://bugs.gnome.org/show_bug.cgi?id=316786
|
|
|
|
# pass btn instance when this bug is over
|
|
|
|
button = self.button_clicked
|
|
|
|
# here I get the coordinates of the button relative to
|
|
|
|
# window (self.window)
|
|
|
|
button_x, button_y = button.allocation.x, button.allocation.y
|
|
|
|
|
|
|
|
# now convert them to X11-relative
|
|
|
|
window_x, window_y = self.parent_win.get_origin()
|
|
|
|
x = window_x + button_x
|
|
|
|
y = window_y + button_y
|
|
|
|
|
|
|
|
menu_width, menu_height = menu.size_request()
|
|
|
|
|
|
|
|
## should we pop down or up?
|
|
|
|
if (y + button.allocation.height + menu_height
|
|
|
|
< gtk.gdk.screen_height()):
|
|
|
|
# now move the menu below the button
|
|
|
|
y += button.allocation.height
|
|
|
|
else:
|
|
|
|
# now move the menu above the button
|
|
|
|
y -= menu_height
|
|
|
|
|
|
|
|
|
|
|
|
# push_in is True so all the menuitems are always inside screen
|
|
|
|
push_in = True
|
|
|
|
return (x, y, push_in)
|
|
|
|
|
2005-12-31 04:53:48 +01:00
|
|
|
|