chat window mockup and related code by Dennis Craven

This commit is contained in:
Nikos Kouremenos 2005-06-07 21:28:21 +00:00
parent d44e881640
commit c96c3c123e
5 changed files with 450 additions and 232 deletions

View File

@ -44,6 +44,7 @@ class Chat:
def __init__(self, plugin, account, widget_name):
self.xml = gtk.glade.XML(GTKGUI_GLADE, widget_name, APP)
self.window = self.xml.get_widget(widget_name)
self.widget_name = widget_name
self.notebook = self.xml.get_widget('chat_notebook')
self.notebook.remove_page(0)
@ -199,14 +200,6 @@ class Chat:
if self.plugin.systray_enabled:
self.plugin.systray.remove_jid(new_jid, self.account)
if self.widget_name == 'tabbed_chat_window':
nontabbed_status_image = self.xmls[jid].get_widget(
'nontabbed_status_image')
if len(self.xmls) > 1:
nontabbed_status_image.hide()
else:
nontabbed_status_image.show()
conversation_textview.grab_focus()
def set_active_tab(self, jid):

View File

@ -580,6 +580,8 @@ class Preferences_window:
self.on_widget_font_set(widg, font_widgets[w])
gajim.config.set('roster_theme', theme)
# begin repainting themed widgets throughout
self.plugin.roster.repaint_themed_widgets()
self.plugin.save_config()
self.plugin.roster.draw_roster()

View File

@ -9867,8 +9867,8 @@ Custom</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="default_width">400</property>
<property name="default_height">320</property>
<property name="default_width">460</property>
<property name="default_height">430</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
@ -9882,9 +9882,10 @@ Custom</property>
<child>
<widget class="GtkNotebook" id="chat_notebook">
<property name="border_width">1</property>
<property name="visible">True</property>
<property name="show_tabs">False</property>
<property name="show_border">False</property>
<property name="show_border">True</property>
<property name="tab_pos">GTK_POS_TOP</property>
<property name="scrollable">True</property>
<property name="enable_popup">True</property>
@ -9893,23 +9894,301 @@ Custom</property>
<child>
<widget class="GtkVBox" id="chats_vbox">
<property name="border_width">4</property>
<property name="border_width">3</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="homogeneous">False</property>
<property name="spacing">1</property>
<child>
<widget class="GtkHBox" id="banner_hbox">
<property name="border_width">3</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkEventBox" id="banner_status_eventbox">
<property name="width_request">40</property>
<property name="height_request">40</property>
<property name="visible">True</property>
<property name="visible_window">True</property>
<property name="above_child">False</property>
<child>
<widget class="GtkImage" id="banner_status_image">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkEventBox" id="banner_name_eventbox">
<property name="visible">True</property>
<property name="visible_window">True</property>
<property name="above_child">False</property>
<child>
<widget class="GtkLabel" id="banner_name_label">
<property name="visible">True</property>
<property name="label">&lt;span weight=&quot;heavy&quot; size=&quot;large&quot;&gt;Contact: name&lt;/span&gt;
JID: whatever@jabber.org</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.0900000035763</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">5</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkEventBox" id="banner_avatar_eventbox">
<property name="width_request">40</property>
<property name="height_request">40</property>
<property name="visible">True</property>
<property name="visible_window">True</property>
<property name="above_child">False</property>
<child>
<widget class="GtkImage" id="image614">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">6</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkVPaned" id="vpaned3">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<widget class="GtkScrolledWindow" id="conversation_scrolledwindow">
<property name="border_width">3</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="conversation_textview">
<property name="border_width">1</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
<property name="cursor_visible">False</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
<signal name="motion_notify_event" handler="on_conversation_textview_motion_notify_event" last_modification_time="Thu, 10 Mar 2005 16:07:43 GMT"/>
<signal name="button_press_event" handler="on_conversation_textview_button_press_event" last_modification_time="Thu, 10 Mar 2005 17:54:22 GMT"/>
<signal name="key_press_event" handler="on_conversation_textview_key_press_event" last_modification_time="Thu, 31 Mar 2005 14:50:51 GMT"/>
<signal name="populate_popup" handler="on_conversation_textview_populate_popup" last_modification_time="Wed, 11 May 2005 19:39:04 GMT"/>
</widget>
</child>
</widget>
<packing>
<property name="shrink">True</property>
<property name="resize">True</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox2957">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow31">
<property name="border_width">3</property>
<property name="height_request">53</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="message_textview">
<property name="border_width">1</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
<property name="cursor_visible">True</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
<signal name="key_press_event" handler="on_message_textview_key_press_event" last_modification_time="Wed, 02 Mar 2005 21:05:35 GMT"/>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="shrink">False</property>
<property name="resize">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="actions_hbox">
<property name="border_width">3</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">5</property>
<child>
<widget class="GtkToggleButton" id="gpg_togglebutton">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Toggle OpenPGP encryption</property>
<property name="relief">GTK_RELIEF_NONE</property>
<property name="focus_on_click">False</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<child>
<widget class="GtkImage" id="image433">
<property name="visible">True</property>
<property name="stock">gtk-dialog-authentication</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label314">
<property name="visible">True</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="contact_button">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Click to get contact's extended information</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_contact_button_clicked" last_modification_time="Tue, 07 Jun 2005 19:49:24 GMT"/>
<child>
<widget class="GtkImage" id="image612">
<property name="visible">True</property>
<property name="stock">gtk-dialog-info</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="history_button">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Click to see past conversations with this contact</property>
<property name="relief">GTK_RELIEF_NONE</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">False</property>
<signal name="clicked" handler="on_history_button_clicked" last_modification_time="Wed, 02 Mar 2005 17:03:17 GMT"/>
@ -9981,14 +10260,8 @@ Custom</property>
</child>
<child>
<widget class="GtkButton" id="clear_button">
<widget class="GtkVSeparator" id="vseparator1">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Click to clear conversation (won't delete it from history)</property>
<property name="label">gtk-clear</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NONE</property>
<property name="focus_on_click">False</property>
<signal name="clicked" handler="on_clear_button_clicked" last_modification_time="Wed, 02 Mar 2005 17:03:09 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
@ -9998,38 +10271,70 @@ Custom</property>
</child>
<child>
<widget class="GtkImage" id="nontabbed_status_image">
<property name="stock">gtk-no</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkToggleButton" id="gpg_togglebutton">
<widget class="GtkButton" id="send_button">
<property name="visible">True</property>
<property name="relief">GTK_RELIEF_NONE</property>
<property name="focus_on_click">False</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_send_button_clicked" last_modification_time="Tue, 07 Jun 2005 20:31:28 GMT"/>
<child>
<widget class="GtkImage" id="image433">
<widget class="GtkAlignment" id="alignment71">
<property name="visible">True</property>
<property name="stock">gtk-dialog-authentication</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox2964">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image611">
<property name="visible">True</property>
<property name="stock">gtk-jump-to</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label313">
<property name="visible">True</property>
<property name="label" translatable="yes">_Send</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
@ -10039,36 +10344,6 @@ Custom</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkFixed" id="fixed">
<property name="width_request">20</property>
<property name="visible">True</property>
<child>
<widget class="GtkButton" id="contact_button">
<property name="width_request">0</property>
<property name="height_request">0</property>
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Click for contact's extented information</property>
<property name="label" translatable="yes">Anonymous &lt;nick@server/res&gt;</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NONE</property>
<property name="focus_on_click">False</property>
<signal name="clicked" handler="on_contact_button_clicked" last_modification_time="Wed, 02 Mar 2005 21:04:43 GMT"/>
</widget>
<packing>
<property name="x">0</property>
<property name="y">2</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
@ -10076,122 +10351,6 @@ Custom</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkVPaned" id="vpaned3">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<widget class="GtkScrolledWindow" id="conversation_scrolledwindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="conversation_textview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
<property name="cursor_visible">False</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
<signal name="motion_notify_event" handler="on_conversation_textview_motion_notify_event" last_modification_time="Thu, 10 Mar 2005 16:07:43 GMT"/>
<signal name="button_press_event" handler="on_conversation_textview_button_press_event" last_modification_time="Thu, 10 Mar 2005 17:54:22 GMT"/>
<signal name="key_press_event" handler="on_conversation_textview_key_press_event" last_modification_time="Thu, 31 Mar 2005 14:50:51 GMT"/>
<signal name="populate_popup" handler="on_conversation_textview_populate_popup" last_modification_time="Wed, 11 May 2005 19:39:04 GMT"/>
</widget>
</child>
</widget>
<packing>
<property name="shrink">True</property>
<property name="resize">True</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox2957">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkImage" id="avatar_image">
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow31">
<property name="height_request">45</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="message_textview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
<property name="cursor_visible">True</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
<signal name="key_press_event" handler="on_message_textview_key_press_event" last_modification_time="Wed, 02 Mar 2005 21:05:35 GMT"/>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="shrink">False</property>
<property name="resize">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>

View File

@ -1316,6 +1316,13 @@ class Roster_window:
self.plugin.windows[account]['gc'][jid].update_state_images()
self.update_status_comboxbox()
def repaint_themed_widgets(self):
"""Notify windows that contain themed widgets to repaint them"""
for account in gajim.connections:
# Update opened chat windows/tabs
for jid in self.plugin.windows[account]['chats']:
self.plugin.windows[account]['chats'][jid].repaint_colored_widgets()
def on_show_offline_contacts_menuitem_activate(self, widget):
'''when show offline option is changed:
redraw the treeview'''

View File

@ -77,18 +77,46 @@ class Tabbed_chat_window(chat.Chat):
self.set_state_image(jid)
contact_button = self.xmls[jid].get_widget('contact_button')
contact_button.set_use_underline(False)
contact_button.set_label(user.name + ' <' + jid + '>')
if not user.keyID:
self.xmls[jid].get_widget('gpg_togglebutton').set_sensitive(False)
else:
self.xmls[jid].get_widget('gpg_togglebutton').set_sensitive(True)
nontabbed_status_image = self.xmls[jid].get_widget(
'nontabbed_status_image')
if len(self.xmls) > 1:
nontabbed_status_image.hide()
else:
nontabbed_status_image.show()
# add the fat line at the top
self.draw_name_banner(user.name, jid)
def draw_name_banner(self, name, jid):
'''Draw the fat line at the top of the window that
houses the status icon, name, jid, and avatar'''
# this is the text for the big brown bar
label_text = '<span weight="heavy" size="x-large">%s</span>\n%s' \
% (name, jid)
# get the bg color of the bar from the current theme colors
bgcolor = gajim.config.get('accountbgcolor')
# the backgrounds are colored by using eventboxes and
# setting the bg color of the eventboxes. There is a
# separate event box for each component (name label and
# status icon). The avatar has one too in the glade file.
# setup the label that holds name and jid
banner_name_label = self.xmls[jid].get_widget('banner_name_label')
banner_name_label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))
banner_name_label.set_markup(label_text)
# setup the eventbox that holds the above label, and colour it
banner_name_eventbox = self.xmls[jid].get_widget('banner_name_eventbox')
banner_name_eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(bgcolor))
# setup the eventbox that holds the status icon and colour it
banner_status_eventbox = self.xmls[jid].get_widget('banner_status_eventbox')
banner_status_eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(bgcolor))
# setup the eventbox that holds the avatar and colour it
banner_avatar_eventbox = self.xmls[jid].get_widget('banner_avatar_eventbox')
banner_avatar_eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(bgcolor))
def set_state_image(self, jid):
prio = 0
@ -109,18 +137,34 @@ class Tabbed_chat_window(chat.Chat):
status_image = self.notebook.get_tab_label(child).get_children()[0]
state_images = self.plugin.roster.get_appropriate_state_images(jid)
image = state_images[show]
non_tabbed_status_image = self.xmls[jid].get_widget(
'nontabbed_status_image')
banner_status_image = self.xmls[jid].get_widget('banner_status_image')
if keyID:
self.xmls[jid].get_widget('gpg_togglebutton').set_sensitive(True)
else:
self.xmls[jid].get_widget('gpg_togglebutton').set_sensitive(False)
if image.get_storage_type() == gtk.IMAGE_ANIMATION:
non_tabbed_status_image.set_from_animation(image.get_animation())
banner_status_image.set_from_animation(image.get_animation())
status_image.set_from_animation(image.get_animation())
elif image.get_storage_type() == gtk.IMAGE_PIXBUF:
non_tabbed_status_image.set_from_pixbuf(image.get_pixbuf())
status_image.set_from_pixbuf(image.get_pixbuf())
# make a copy because one will be scaled, one not (tab icon)
pix = image.get_pixbuf()
scaled_pix = pix.scale_simple(32, 32, gtk.gdk.INTERP_BILINEAR)
banner_status_image.set_from_pixbuf(scaled_pix)
status_image.set_from_pixbuf(pix)
def repaint_colored_widgets(self):
"""Repaint widgets (banner) in the window/tab with theme color"""
# get the bg color of the bar from the current theme colors
bgcolor = gajim.config.get('accountbgcolor')
# iterate through tabs/windows and repaint
for jid in self.xmls:
banner_status_eventbox = self.xmls[jid].get_widget('banner_status_eventbox')
banner_status_eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(bgcolor))
banner_name_eventbox = self.xmls[jid].get_widget('banner_name_eventbox')
banner_name_eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(bgcolor))
banner_avatar_eventbox = self.xmls[jid].get_widget('banner_avatar_eventbox')
banner_avatar_eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(bgcolor))
def on_tabbed_chat_window_delete_event(self, widget, event):
"""close window"""
@ -142,11 +186,7 @@ class Tabbed_chat_window(chat.Chat):
def on_chat_notebook_key_press_event(self, widget, event):
chat.Chat.on_chat_notebook_key_press_event(self, widget, event)
def on_clear_button_clicked(self, widget):
"""When clear button is pressed: clear the conversation"""
jid = self.get_active_jid()
textview = self.xmls[jid].get_widget('conversation_textview')
self.on_clear(None, textview)
# clear button is no longer: function removed
def on_history_button_clicked(self, widget):
"""When history button is pressed: call history window"""
@ -157,6 +197,20 @@ class Tabbed_chat_window(chat.Chat):
self.plugin.windows['logs'][jid] = history_window.\
History_window(self.plugin, jid, self.account)
def on_send_button_clicked(self, widget):
"""When send button is pressed: send the current message"""
jid = self.get_active_jid()
message_textview = self.xmls[jid].get_widget('message_textview')
message_buffer = message_textview.get_buffer()
start_iter = message_buffer.get_start_iter()
end_iter = message_buffer.get_end_iter()
message = message_buffer.get_text(start_iter, end_iter, 0)
# send the message
self.send_message(message)
message_buffer.set_text('', -1)
def remove_tab(self, jid):
if time.time() - self.last_message_time[jid] < 2:
dialog = dialogs.Confirmation_dialog(
@ -169,15 +223,6 @@ class Tabbed_chat_window(chat.Chat):
if len(self.xmls) > 0:
del self.users[jid]
jid = self.get_active_jid() # get the new active jid
if jid != '':
nontabbed_status_image = self.xmls[jid].get_widget(
'nontabbed_status_image')
if len(self.xmls) > 1:
nontabbed_status_image.hide()
else:
nontabbed_status_image.show()
def new_user(self, user):
'''when new tab is created'''
self.names[user.jid] = user.name
@ -240,20 +285,11 @@ class Tabbed_chat_window(chat.Chat):
dialogs.Error_dialog(_("A connection is not available"),
_("Your message can't be sent until you reconnect.")).get_response()
return True
if message != '' or message != '\n':
self.save_sent_message(jid, message)
if message == '/clear':
self.on_clear(None, conversation_textview) # clear conversation
self.on_clear(None, widget) # clear message textview too
return True
keyID = ''
encrypted = False
if self.xmls[jid].get_widget('gpg_togglebutton').get_active():
keyID = self.users[jid].keyID
encrypted = True
gajim.connections[self.account].send_message(jid, message, keyID)
message_buffer.set_text('', -1)
self.print_conversation(message, jid, jid, encrypted = encrypted)
# send the message
self.send_message(message)
message_buffer.set_text('', -1)
return True
elif event.keyval == gtk.keysyms.Up:
if event.state & gtk.gdk.CONTROL_MASK: #Ctrl+UP
@ -262,6 +298,27 @@ class Tabbed_chat_window(chat.Chat):
if event.state & gtk.gdk.CONTROL_MASK: #Ctrl+Down
self.sent_messages_scroll(jid, 'down', widget.get_buffer())
def send_message(self, message):
"""Send the message given in the args"""
jid = self.get_active_jid()
conversation_textview = self.xmls[jid].get_widget('conversation_textview')
message_textview = self.xmls[jid].get_widget('message_textview')
message_buffer = message_textview.get_buffer()
if message != '' or message != '\n':
self.save_sent_message(jid, message)
if message == '/clear':
self.on_clear(None, conversation_textview) # clear conversation
self.on_clear(None, widget) # clear message textview too
return True
keyID = ''
encrypted = False
if self.xmls[jid].get_widget('gpg_togglebutton').get_active():
keyID = self.users[jid].keyID
encrypted = True
gajim.connections[self.account].send_message(jid, message, keyID)
message_buffer.set_text('', -1)
self.print_conversation(message, jid, jid, encrypted = encrypted)
def on_contact_button_clicked(self, widget):
jid = self.get_active_jid()
user = self.users[jid]