source: epoptes/trunk/fuentes/epoptes/ui/sendmessage.py @ 295

Last change on this file since 295 was 295, checked in by mabarracus, 4 years ago

copy trusty epoptes code

File size: 2.5 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4###########################################################################
5# Message sending.
6#
7# Copyright (C) 2010 Fotis Tsamis <ftsamis@gmail.com>
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FINESS FOR A PARTICULAR PURPOSE.  See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21#
22# On Debian GNU/Linux systems, the complete text of the GNU General
23# Public License can be found in `/usr/share/common-licenses/GPL".
24###########################################################################
25
26import gtk
27import os
28import pygtk
29
30from epoptes.common import config
31
32pygtk.require('2.0')
33
34wTree = gtk.Builder()
35get = lambda obj: wTree.get_object(obj)
36
37def startSendMessageDlg():
38    """
39    Retrieve dialog window from glade format and
40    according to type of message requested to send
41    Returns: a 2-tuple containing the message text
42    and the message type.
43    """
44
45    wTree.add_from_file('sendMessage.ui')
46    dlg = get('sendMessageDialog')
47   
48    textView = get('Message')
49    title_entry = get('title_entry')
50    title_entry.set_text(config.settings.get('GUI', 'messages_default_title'))
51    use_markup_toggle = get('use_markup_toggle')
52    use_markup_toggle.set_active(config.settings.getboolean('GUI', 'messages_use_markup'))
53   
54    reply = dlg.run()
55    msg = ()
56   
57    if reply == 1:
58        buf = textView.get_buffer()
59        s = buf.get_start_iter()
60        e = buf.get_end_iter()
61        text = textView.get_buffer().get_text(s,e)
62
63        title = title_entry.get_text().strip()
64       
65        use_markup = use_markup_toggle.get_active()
66       
67        msg = (text, title, use_markup)
68
69        config.settings.set('GUI', 'messages_default_title', title)
70        config.settings.set('GUI', 'messages_use_markup', str(use_markup))
71   
72        f = open(os.path.expanduser('~/.config/epoptes/settings'), 'w')
73        config.settings.write(f)
74        f.close()
75    # Hide dialog after any kind of function
76    dlg.hide()
77
78    # Return the command to be executed on clients
79    return msg
Note: See TracBrowser for help on using the repository browser.