Better User Mood dialog.
This commit is contained in:
parent
d46995ad8e
commit
4178ec7fcb
|
@ -14,10 +14,245 @@
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkTable" id="table1">
|
<widget class="GtkTable" id="table1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="n_rows">2</property>
|
<property name="n_rows">3</property>
|
||||||
<property name="n_columns">2</property>
|
<property name="n_columns">2</property>
|
||||||
<property name="column_spacing">6</property>
|
<property name="column_spacing">6</property>
|
||||||
<property name="row_spacing">6</property>
|
<property name="row_spacing">6</property>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkLabel" id="mood_label">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="label" translatable="yes">None</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="right_attach">2</property>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
<property name="bottom_attach">2</property>
|
||||||
|
<property name="y_options"></property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkTable" id="mood_icons_table">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="n_rows">6</property>
|
||||||
|
<property name="n_columns">11</property>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkRadioButton" id="no_mood_button">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="tooltip_text">No mood</property>
|
||||||
|
<property name="relief">GTK_RELIEF_NONE</property>
|
||||||
|
<property name="response_id">0</property>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkImage" id="image1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="stock">gtk-cancel</property>
|
||||||
|
<property name="icon_size">1</property>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="right_attach">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkEntry" id="description_entry">
|
<widget class="GtkEntry" id="description_entry">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -26,27 +261,20 @@
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
<property name="right_attach">2</property>
|
<property name="right_attach">2</property>
|
||||||
<property name="top_attach">1</property>
|
<property name="top_attach">2</property>
|
||||||
<property name="bottom_attach">2</property>
|
<property name="bottom_attach">3</property>
|
||||||
<property name="y_options"></property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<widget class="GtkComboBox" id="type_combobox">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="right_attach">2</property>
|
|
||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkLabel" id="label">
|
<widget class="GtkLabel" id="label">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="label" translatable="yes">Type:</property>
|
<property name="label" translatable="yes"><b>Mood:</b></property>
|
||||||
|
<property name="use_markup">True</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
<property name="bottom_attach">2</property>
|
||||||
<property name="x_options"></property>
|
<property name="x_options"></property>
|
||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
</packing>
|
</packing>
|
||||||
|
@ -54,11 +282,12 @@
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkLabel" id="label2">
|
<widget class="GtkLabel" id="label2">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="label" translatable="yes">Message:</property>
|
<property name="label" translatable="yes"><b>Message:</b></property>
|
||||||
|
<property name="use_markup">True</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="top_attach">1</property>
|
<property name="top_attach">2</property>
|
||||||
<property name="bottom_attach">2</property>
|
<property name="bottom_attach">3</property>
|
||||||
<property name="x_options"></property>
|
<property name="x_options"></property>
|
||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
</packing>
|
</packing>
|
||||||
|
|
|
@ -37,7 +37,7 @@ import message_control
|
||||||
import dataforms_widget
|
import dataforms_widget
|
||||||
|
|
||||||
from random import randrange
|
from random import randrange
|
||||||
from common.pep import MOODS
|
from common import pep
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import gtkspell
|
import gtkspell
|
||||||
|
@ -431,7 +431,6 @@ class ChangeActivityDialog:
|
||||||
message = self.entry.get_text().decode('utf-8')
|
message = self.entry.get_text().decode('utf-8')
|
||||||
if subactivity is None:
|
if subactivity is None:
|
||||||
subactivity = ''
|
subactivity = ''
|
||||||
from common import pep
|
|
||||||
if activity == 'None':
|
if activity == 'None':
|
||||||
pep.user_retract_activity(self.account)
|
pep.user_retract_activity(self.account)
|
||||||
else:
|
else:
|
||||||
|
@ -443,52 +442,82 @@ class ChangeActivityDialog:
|
||||||
self.window.destroy()
|
self.window.destroy()
|
||||||
|
|
||||||
class ChangeMoodDialog:
|
class ChangeMoodDialog:
|
||||||
moods = MOODS
|
COLS = 11
|
||||||
|
|
||||||
def __init__(self, account):
|
def __init__(self, account):
|
||||||
self.account = account
|
self.account = account
|
||||||
self.xml = gtkgui_helpers.get_glade('change_mood_dialog.glade')
|
self.xml = gtkgui_helpers.get_glade('change_mood_dialog.glade')
|
||||||
|
self.mood = None
|
||||||
|
|
||||||
self.window = self.xml.get_widget('change_mood_dialog')
|
self.window = self.xml.get_widget('change_mood_dialog')
|
||||||
self.window.set_transient_for(gajim.interface.roster.window)
|
self.window.set_transient_for(gajim.interface.roster.window)
|
||||||
self.window.set_title(_('Set Mood'))
|
self.window.set_title(_('Set Mood'))
|
||||||
|
|
||||||
|
table = self.xml.get_widget('mood_icons_table')
|
||||||
|
self.label = self.xml.get_widget('mood_label')
|
||||||
self.entry = self.xml.get_widget('description_entry')
|
self.entry = self.xml.get_widget('description_entry')
|
||||||
|
|
||||||
self.combo = self.xml.get_widget('type_combobox')
|
no_mood_button = self.xml.get_widget('no_mood_button')
|
||||||
self.liststore = gtk.ListStore(str, str) # translated, english
|
no_mood_button.set_mode(False)
|
||||||
self.combo.set_model(self.liststore)
|
no_mood_button.connect('clicked',
|
||||||
|
self.on_mood_button_clicked, None)
|
||||||
|
|
||||||
for mood in self.moods:
|
x = 1
|
||||||
self.liststore.append((helpers.get_uf_mood(mood), mood))
|
y = 0
|
||||||
|
self.mood_buttons = {}
|
||||||
|
for mood in pep.MOODS:
|
||||||
|
self.mood_buttons[mood] = gtk.RadioButton(
|
||||||
|
no_mood_button)
|
||||||
|
self.mood_buttons[mood].set_mode(False)
|
||||||
|
self.mood_buttons[mood].add(
|
||||||
|
gtkgui_helpers.load_mood_icon(mood))
|
||||||
|
self.mood_buttons[mood].set_relief(gtk.RELIEF_NONE)
|
||||||
|
self.mood_buttons[mood].set_tooltip_text(_(mood))
|
||||||
|
self.mood_buttons[mood].connect('clicked',
|
||||||
|
self.on_mood_button_clicked, mood)
|
||||||
|
table.attach(self.mood_buttons[mood],
|
||||||
|
x, x + 1, y, y + 1)
|
||||||
|
|
||||||
|
# Calculate the next position
|
||||||
|
x += 1
|
||||||
|
if x >= self.COLS:
|
||||||
|
x = 0
|
||||||
|
y += 1
|
||||||
|
|
||||||
con = gajim.connections[account]
|
con = gajim.connections[account]
|
||||||
if 'mood' in con.mood and con.mood['mood'] in self.moods:
|
if 'mood' in con.mood:
|
||||||
self.combo.set_active(self.moods.index(con.mood['mood']))
|
self.mood = con.mood['mood']
|
||||||
else:
|
self.label.set_text(con.mood['mood'])
|
||||||
self.combo.set_active(0)
|
if con.mood['mood'] in pep.MOODS:
|
||||||
|
self.mood_buttons[con.mood['mood']]. \
|
||||||
|
set_active(True)
|
||||||
|
|
||||||
|
self.entry.set_sensitive(True if self.mood else False)
|
||||||
|
|
||||||
if 'text' in con.mood:
|
if 'text' in con.mood:
|
||||||
self.entry.set_text(con.mood['text'])
|
self.entry.set_text(con.mood['text'])
|
||||||
|
|
||||||
cellrenderertext = gtk.CellRendererText()
|
|
||||||
self.combo.pack_start(cellrenderertext, True)
|
|
||||||
self.combo.add_attribute(cellrenderertext, 'text', 0)
|
|
||||||
self.xml.signal_autoconnect(self)
|
self.xml.signal_autoconnect(self)
|
||||||
self.window.show_all()
|
self.window.show_all()
|
||||||
|
|
||||||
|
def on_mood_button_clicked(self, widget, data):
|
||||||
|
self.label.set_text(_(data))
|
||||||
|
|
||||||
|
if data:
|
||||||
|
self.entry.set_sensitive(True)
|
||||||
|
else:
|
||||||
|
self.entry.set_text('')
|
||||||
|
self.entry.set_sensitive(False)
|
||||||
|
self.mood = data
|
||||||
|
|
||||||
def on_ok_button_clicked(self, widget):
|
def on_ok_button_clicked(self, widget):
|
||||||
'''Return mood and messsage (None if no mood selected)'''
|
'''Return mood and messsage (None if no mood selected)'''
|
||||||
mood = None
|
message = self.entry.get_text().decode('utf-8')
|
||||||
message = None
|
if self.mood is None:
|
||||||
active = self.combo.get_active()
|
pep.user_retract_mood(self.account)
|
||||||
if active > -1:
|
else:
|
||||||
mood = self.liststore[active][1].decode('utf-8')
|
pep.user_send_mood(self.account, self.mood, message)
|
||||||
message = self.entry.get_text().decode('utf-8')
|
self.window.destroy()
|
||||||
from common import pep
|
|
||||||
if mood == 'None':
|
|
||||||
pep.user_retract_mood(self.account)
|
|
||||||
else:
|
|
||||||
pep.user_send_mood(self.account, mood, message)
|
|
||||||
self.window.destroy()
|
|
||||||
|
|
||||||
def on_cancel_button_clicked(self, widget):
|
def on_cancel_button_clicked(self, widget):
|
||||||
self.window.destroy()
|
self.window.destroy()
|
||||||
|
|
Loading…
Reference in New Issue