Skip to content
Snippets Groups Projects
Commit 7dcf23b1 authored by Sébastien Helleu's avatar Sébastien Helleu
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
Showing with 479 additions and 0 deletions
# Ignored files for Git
MANIFEST
build/*
dist/*
*.pyc
AUTHORS 0 → 100644
QWeeChat authors
================
Developers
----------
* General code
** Sébastien Helleu <flashcode@flashtux.org>
*** Web: http://www.weechat.org/
*** IRC: 'FlashCode' on irc.freenode.net
Contributors
------------
* Florian Besser <fbesser@gmail.com>, IRC: 'Banton'
Contact
-------
Whole team is connected to IRC:
server: 'irc.freenode.net', channels: '#weechat' (english) and '#weechat-fr' (french)
See README file for license detail.
This diff is collapsed.
INSTALL 0 → 100644
QWeeChat installation
=====================
Required to run QWeeChat:
- python 2.x >= 2.6
- PyQt4 (python-qt4) or PySide (python.pyside.*)
Run without install
-------------------
Extract files from archive and run qweechat.py:
$ tar xvzf qweechat-x.y.tar.gz
$ cd qweechat-x.y
$ python src/qweechat/weechat.py
Install
-------
Extract files from archive and install using script 'setup.py':
$ tar xvzf qweechat-x.y.tar.gz
$ cd qweechat-x.y
$ python setup.py install
See AUTHORS for support, feel free to contact us for any problem.
include MANIFEST.in
include AUTHORS
include COPYING
include INSTALL
README 0 → 100644
QWeeChat readme
===============
QWeeChat is a Qt remote GUI for WeeChat written in Python.
It requires WeeChat (version >= 0.3.7) on local or remote machine, with
relay plugin enabled and listening on a port for protocol "weechat".
Features
--------
* multi-platform (GNU/Linux, *BSD, Mac OS X, QNX, Windows & other)
* free software, released under GPLv3
Copyright
---------
Copyright (C) 2011 Sébastien Helleu <flashcode@flashtux.org>
This file is part of QWeeChat, a Qt remote GUI for WeeChat.
QWeeChat 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; either version 3 of the License, or
(at your option) any later version.
QWeeChat 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.
You should have received a copy of the GNU General Public License
along with QWeeChat. If not, see <http://www.gnu.org/licenses/>.
data/icons/application-exit.png

1.72 KiB

data/icons/dialog-close.png

813 B

data/icons/dialog-ok-apply.png

597 B

data/icons/edit-find.png

1.67 KiB

data/icons/help-about.png

1.6 KiB

data/icons/network-connect.png

1.64 KiB

data/icons/network-disconnect.png

1.25 KiB

data/icons/preferences-other.png

1.86 KiB

setup.py 0 → 100755
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Sebastien Helleu <flashcode@flashtux.org>
#
# This file is part of QWeeChat, a Qt remote GUI for WeeChat.
#
# QWeeChat 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; either version 3 of the License, or
# (at your option) any later version.
#
# QWeeChat 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.
#
# You should have received a copy of the GNU General Public License
# along with QWeeChat. If not, see <http://www.gnu.org/licenses/>.
#
import os
from distutils.core import setup
def listfiles(dir):
return ['%s/%s' % (dir, f) for f in os.listdir(dir)]
setup(name='qweechat',
version='0.1-dev',
description='Qt remote GUI for WeeChat',
long_description='Qt remote GUI for WeeChat',
author='Sébastien Helleu',
author_email='flashcode@flashtux.org',
url='http://www.weechat.org/',
license='GPL3',
classifiers = ['Development Status :: 2 - Pre-Alpha',
'Environment :: X11 Applications :: Qt',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: GNU General Public License (GPL)',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Communications :: Chat',
],
platforms='OS Independent',
packages=['qweechat',
'qweechat.weechat',
],
package_dir={'qweechat': 'src/qweechat',
'qweechat.weechat': 'src/qweechat/weechat',
},
data_files=[('data/icons', listfiles('data/icons'))]
)
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Sebastien Helleu <flashcode@flashtux.org>
#
# This file is part of QWeeChat, a Qt remote GUI for WeeChat.
#
# QWeeChat 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; either version 3 of the License, or
# (at your option) any later version.
#
# QWeeChat 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.
#
# You should have received a copy of the GNU General Public License
# along with QWeeChat. If not, see <http://www.gnu.org/licenses/>.
#
#
# About dialog box.
#
import qt_compat
QtCore = qt_compat.import_module('QtCore')
QtGui = qt_compat.import_module('QtGui')
class AboutDialog(QtGui.QDialog):
"""About dialog."""
def __init__(self, name, messages, *args):
apply(QtGui.QDialog.__init__, (self,) + args)
self.setModal(True)
self.setWindowTitle(name)
close_button = QtGui.QPushButton('Close')
close_button.pressed.connect(self.close)
hbox = QtGui.QHBoxLayout()
hbox.addStretch(1)
hbox.addWidget(close_button)
hbox.addStretch(1)
vbox = QtGui.QVBoxLayout()
for msg in messages:
label = QtGui.QLabel(msg.decode('utf-8'))
label.setAlignment(QtCore.Qt.AlignHCenter)
vbox.addWidget(label)
vbox.addLayout(hbox)
self.setLayout(vbox)
self.show()
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Sebastien Helleu <flashcode@flashtux.org>
#
# This file is part of QWeeChat, a Qt remote GUI for WeeChat.
#
# QWeeChat 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; either version 3 of the License, or
# (at your option) any later version.
#
# QWeeChat 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.
#
# You should have received a copy of the GNU General Public License
# along with QWeeChat. If not, see <http://www.gnu.org/licenses/>.
#
#
# Buffers.
#
import qt_compat
QtCore = qt_compat.import_module('QtCore')
QtGui = qt_compat.import_module('QtGui')
from chat import ChatTextEdit
from input import InputLineEdit
class BufferListWidget(QtGui.QListWidget):
"""Widget with list of buffers."""
def __init__(self, *args):
apply(QtGui.QListWidget.__init__, (self,) + args)
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.setMinimumWidth(120)
self.setMaximumWidth(200)
# TODO: do a dynamic size for widget
#self.setMinimumWidth(self.sizeHintForColumn(0))
#self.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.MinimumExpanding)
#self.setResizeMode(QtGui.QListView.Adjust)
self.setFocusPolicy(QtCore.Qt.NoFocus)
pal = self.palette()
pal.setColor(QtGui.QPalette.Highlight, QtGui.QColor('#ddddff'))
pal.setColor(QtGui.QPalette.HighlightedText, QtGui.QColor('black'))
self.setPalette(pal)
# TODO: do a dynamic size for widget
def sizeHint(self):
s = QtCore.QSize()
s.setHeight(super(BufferListWidget,self).sizeHint().height())
s.setWidth(self.sizeHintForColumn(0))
return s
def switch_prev_buffer(self):
if self.currentRow() > 0:
self.setCurrentRow(self.currentRow() - 1)
else:
self.setCurrentRow(self.count() - 1)
def switch_next_buffer(self):
if self.currentRow() < self.count() - 1:
self.setCurrentRow(self.currentRow() + 1)
else:
self.setCurrentRow(0)
class BufferWidget(QtGui.QWidget):
"""Widget with (from top to bottom): title, chat + nicklist (optional) + prompt/input."""
def __init__(self, display_nicklist=False):
QtGui.QWidget.__init__(self)
# title
self.title = QtGui.QLineEdit()
# splitter with chat + nicklist
self.chat_nicklist = QtGui.QSplitter()
self.chat_nicklist.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
self.chat = ChatTextEdit()
self.chat_nicklist.addWidget(self.chat)
self.nicklist = QtGui.QListWidget()
self.nicklist.setMaximumWidth(100)
self.nicklist.setFocusPolicy(QtCore.Qt.NoFocus)
if not display_nicklist:
self.nicklist.setVisible(False)
self.chat_nicklist.addWidget(self.nicklist)
# prompt + input
hbox_edit = QtGui.QHBoxLayout()
hbox_edit.setContentsMargins(0, 0, 0, 0)
hbox_edit.setSpacing(0)
self.prompt = QtGui.QLabel('FlashCode')
self.prompt.setContentsMargins(0, 0, 5, 0)
hbox_edit.addWidget(self.prompt)
self.input = InputLineEdit(self.chat)
hbox_edit.addWidget(self.input)
prompt_input = QtGui.QWidget()
prompt_input.setLayout(hbox_edit)
prompt_input.setContentsMargins(0, 0, 0, 0)
# vbox with title + chat/nicklist + prompt/input
vbox = QtGui.QVBoxLayout()
vbox.setContentsMargins(0, 0, 0, 0)
vbox.setSpacing(0)
vbox.addWidget(self.title)
vbox.addWidget(self.chat_nicklist)
vbox.addWidget(prompt_input)
self.setLayout(vbox)
def set_title(self, title):
"""Set buffer title."""
self.title.clear()
if not title is None:
self.title.setText(title)
class Buffer(QtCore.QObject):
"""A WeeChat buffer."""
bufferInput = qt_compat.Signal(str, str)
def __init__(self, data={}):
QtCore.QObject.__init__(self)
self.data = data
self.widget = BufferWidget(display_nicklist=self.data.get('nicklist', 0))
if self.data and self.data['title']:
self.widget.set_title(self.data['title'])
self.widget.input.textSent.connect(self.input_text_sent)
def pointer(self):
"""Return pointer on buffer."""
return self.data.get('__path', [''])[0]
def input_text_sent(self, text):
"""Called when text has to be sent to buffer."""
if self.data:
self.bufferInput.emit(self.data['full_name'], text)
def add_nick(self, prefix, nick):
"""Add a nick to nicklist."""
self.widget.nicklist.addItem('%s%s' % (prefix, nick))
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Sebastien Helleu <flashcode@flashtux.org>
#
# This file is part of QWeeChat, a Qt remote GUI for WeeChat.
#
# QWeeChat 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; either version 3 of the License, or
# (at your option) any later version.
#
# QWeeChat 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.
#
# You should have received a copy of the GNU General Public License
# along with QWeeChat. If not, see <http://www.gnu.org/licenses/>.
#
#
# Chat area.
#
import datetime
import qt_compat
QtCore = qt_compat.import_module('QtCore')
QtGui = qt_compat.import_module('QtGui')
class ChatTextEdit(QtGui.QTextEdit):
"""Chat area."""
def __init__(self, *args):
apply(QtGui.QTextEdit.__init__, (self,) + args)
self.readOnly = True
self.setFocusPolicy(QtCore.Qt.NoFocus)
self.setFontFamily('monospace')
def display(self, time, prefix, text, color=None):
oldcolor = self.textColor()
if time == 0:
d = datetime.datetime.now()
else:
d = datetime.datetime.fromtimestamp(float(time))
self.setTextColor(QtGui.QColor('#999999'))
self.insertPlainText(d.strftime('%H:%M '))
self.setTextColor(oldcolor)
if prefix:
self.insertPlainText(str(prefix).decode('utf-8') + ' ')
if color:
self.setTextColor(QtGui.QColor(color))
self.insertPlainText(str(text).decode('utf-8'))
if text[-1:] != '\n':
self.insertPlainText('\n')
if color:
self.setTextColor(oldcolor)
self.scroll_bottom()
def scroll_bottom(self):
bar = self.verticalScrollBar()
bar.setValue(bar.maximum())
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011 Sebastien Helleu <flashcode@flashtux.org>
#
# This file is part of QWeeChat, a Qt remote GUI for WeeChat.
#
# QWeeChat 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; either version 3 of the License, or
# (at your option) any later version.
#
# QWeeChat 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.
#
# You should have received a copy of the GNU General Public License
# along with QWeeChat. If not, see <http://www.gnu.org/licenses/>.
#
#
# Configuration for QWeeChat (~/.qweechat/qweechat.conf)
#
import os, ConfigParser
CONFIG_DIR = '%s/.qweechat' % os.getenv('HOME')
CONFIG_FILENAME = '%s/qweechat.conf' % CONFIG_DIR
CONFIG_DEFAULT_SECTIONS = ('relay', 'look')
CONFIG_DEFAULT_OPTIONS = (('relay.server', ''),
('relay.port', ''),
('relay.password', ''),
('relay.autoconnect', 'off'),
('look.debug', 'off'),
('look.statusbar', 'off'))
def read():
"""Read config file."""
config = ConfigParser.RawConfigParser()
if os.path.isfile(CONFIG_FILENAME):
config.read(CONFIG_FILENAME)
# add missing sections/options
for section in CONFIG_DEFAULT_SECTIONS:
if not config.has_section(section):
config.add_section(section)
for option in reversed(CONFIG_DEFAULT_OPTIONS):
section, name = option[0].split('.', 1)
if not config.has_option(section, name):
config.set(section, name, option[1])
return config
def write(config):
"""Write config file."""
if not os.path.exists(CONFIG_DIR):
os.mkdir(CONFIG_DIR, 0755)
with open(CONFIG_FILENAME, 'wb') as cfg:
config.write(cfg)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment