| ... |
... |
@@ -18,7 +18,6 @@ from gi.repository import Gtk |
|
18
|
18
|
from gajim.common import app
|
|
19
|
19
|
from gajim.common.const import ACTIVITIES
|
|
20
|
20
|
from gajim.common.const import MOODS
|
|
21
|
|
-from gajim.common.const import PEPEventType
|
|
22
|
21
|
from gajim.common.helpers import from_one_line
|
|
23
|
22
|
from gajim.common.helpers import to_one_line
|
|
24
|
23
|
from gajim.common.helpers import remove_invalid_xml_chars
|
| ... |
... |
@@ -77,7 +76,7 @@ class StatusChange(Gtk.ApplicationWindow, TimeoutWindow): |
|
77
|
76
|
'mood': '',
|
|
78
|
77
|
}
|
|
79
|
78
|
self._get_current_status_data()
|
|
80
|
|
- self._preset_messages_dict = {}
|
|
|
79
|
+ self._presets = {}
|
|
81
|
80
|
self._get_presets()
|
|
82
|
81
|
|
|
83
|
82
|
if self._status:
|
| ... |
... |
@@ -91,11 +90,13 @@ class StatusChange(Gtk.ApplicationWindow, TimeoutWindow): |
|
91
|
90
|
self._apply_speller()
|
|
92
|
91
|
self._message_buffer.set_text(from_one_line(self._status_message))
|
|
93
|
92
|
|
|
|
93
|
+ self._activity_btns = {}
|
|
|
94
|
+ self._mood_btns = {}
|
|
94
|
95
|
if show_pep:
|
|
95
|
|
- self._draw_activity()
|
|
96
|
96
|
self._init_activities()
|
|
97
|
|
- self._draw_mood()
|
|
|
97
|
+ self._draw_activity()
|
|
98
|
98
|
self._init_moods()
|
|
|
99
|
+ self._draw_mood()
|
|
99
|
100
|
else:
|
|
100
|
101
|
self._ui.pep_grid.set_no_show_all(True)
|
|
101
|
102
|
self._ui.pep_grid.hide()
|
| ... |
... |
@@ -138,11 +139,11 @@ class StatusChange(Gtk.ApplicationWindow, TimeoutWindow): |
|
138
|
139
|
are synchronized. If not, no status message/pep data will be displayed.
|
|
139
|
140
|
'''
|
|
140
|
141
|
if self.account:
|
|
141
|
|
- self._status_message = app.connections[self.account].status_message
|
|
142
|
|
- activity_data = app.connections[self.account].pep.get(
|
|
143
|
|
- PEPEventType.ACTIVITY)
|
|
144
|
|
- mood_data = app.connections[self.account].pep.get(
|
|
145
|
|
- PEPEventType.MOOD)
|
|
|
142
|
+ client = app.get_client(self.account)
|
|
|
143
|
+ self._status_message = client.status_message
|
|
|
144
|
+ activity_data = client.get_module(
|
|
|
145
|
+ 'UserActivity').get_current_activity()
|
|
|
146
|
+ mood_data = client.get_module('UserMood').get_current_mood()
|
|
146
|
147
|
if activity_data:
|
|
147
|
148
|
self._pep_dict['activity'] = activity_data.activity
|
|
148
|
149
|
self._pep_dict['subactivity'] = activity_data.subactivity
|
| ... |
... |
@@ -154,10 +155,15 @@ class StatusChange(Gtk.ApplicationWindow, TimeoutWindow): |
|
154
|
155
|
subactivities = []
|
|
155
|
156
|
moods = []
|
|
156
|
157
|
for account in app.connections:
|
|
157
|
|
- status_messages.append(app.connections[account].status_message)
|
|
158
|
|
- activity_data = app.connections[account].pep.get(
|
|
159
|
|
- PEPEventType.ACTIVITY)
|
|
160
|
|
- mood_data = app.connections[account].pep.get(PEPEventType.MOOD)
|
|
|
158
|
+ client = app.get_client(account)
|
|
|
159
|
+ if not app.config.get_per('accounts', client.account,
|
|
|
160
|
+ 'sync_with_global_status'):
|
|
|
161
|
+ continue
|
|
|
162
|
+
|
|
|
163
|
+ status_messages.append(client.status_message)
|
|
|
164
|
+ activity_data = client.get_module(
|
|
|
165
|
+ 'UserActivity').get_current_activity()
|
|
|
166
|
+ mood_data = client.get_module('UserMood').get_current_mood()
|
|
161
|
167
|
if activity_data:
|
|
162
|
168
|
activities.append(activity_data.activity)
|
|
163
|
169
|
subactivities.append(activity_data.subactivity)
|
| ... |
... |
@@ -169,7 +175,7 @@ class StatusChange(Gtk.ApplicationWindow, TimeoutWindow): |
|
169
|
175
|
equal_subactivities = all(x == subactivities[0] for x in
|
|
170
|
176
|
subactivities)
|
|
171
|
177
|
equal_moods = all(x == moods[0] for x in moods)
|
|
172
|
|
- if equal_messages:
|
|
|
178
|
+ if status_messages and equal_messages:
|
|
173
|
179
|
self._status_message = status_messages[0]
|
|
174
|
180
|
if activities and equal_activities:
|
|
175
|
181
|
self._pep_dict['activity'] = activities[0]
|
| ... |
... |
@@ -179,7 +185,7 @@ class StatusChange(Gtk.ApplicationWindow, TimeoutWindow): |
|
179
|
185
|
self._pep_dict['mood'] = moods[0]
|
|
180
|
186
|
|
|
181
|
187
|
def _get_presets(self):
|
|
182
|
|
- self._preset_messages_dict = {}
|
|
|
188
|
+ self._presets = {}
|
|
183
|
189
|
for msg_name in app.config.get_per('statusmsg'):
|
|
184
|
190
|
if msg_name.startswith('_last_'):
|
|
185
|
191
|
continue
|
| ... |
... |
@@ -187,7 +193,7 @@ class StatusChange(Gtk.ApplicationWindow, TimeoutWindow): |
|
187
|
193
|
for opt in ['message', 'activity', 'subactivity', 'mood']:
|
|
188
|
194
|
opts.append(app.config.get_per('statusmsg', msg_name, opt))
|
|
189
|
195
|
opts[0] = from_one_line(opts[0])
|
|
190
|
|
- self._preset_messages_dict[msg_name] = opts
|
|
|
196
|
+ self._presets[msg_name] = opts
|
|
191
|
197
|
self._build_preset_popover()
|
|
192
|
198
|
|
|
193
|
199
|
def _build_preset_popover(self):
|
| ... |
... |
@@ -199,7 +205,7 @@ class StatusChange(Gtk.ApplicationWindow, TimeoutWindow): |
|
199
|
205
|
preset_box.get_style_context().add_class('margin-3')
|
|
200
|
206
|
self._ui.preset_popover.add(preset_box)
|
|
201
|
207
|
|
|
202
|
|
- for preset in self._preset_messages_dict:
|
|
|
208
|
+ for preset in self._presets:
|
|
203
|
209
|
button_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
|
204
|
210
|
|
|
205
|
211
|
preset_button = Gtk.Button()
|
| ... |
... |
@@ -222,7 +228,6 @@ class StatusChange(Gtk.ApplicationWindow, TimeoutWindow): |
|
222
|
228
|
preset_box.show_all()
|
|
223
|
229
|
|
|
224
|
230
|
def _init_activities(self):
|
|
225
|
|
- radio_btns = {}
|
|
226
|
231
|
group = None
|
|
227
|
232
|
|
|
228
|
233
|
for category in ACTIVITIES:
|
| ... |
... |
@@ -236,10 +241,10 @@ class StatusChange(Gtk.ApplicationWindow, TimeoutWindow): |
|
236
|
241
|
# Other
|
|
237
|
242
|
act = category + '_other'
|
|
238
|
243
|
if group:
|
|
239
|
|
- radio_btns[act] = Gtk.RadioButton()
|
|
240
|
|
- radio_btns[act].join_group(group)
|
|
|
244
|
+ self._activity_btns[act] = Gtk.RadioButton()
|
|
|
245
|
+ self._activity_btns[act].join_group(group)
|
|
241
|
246
|
else:
|
|
242
|
|
- radio_btns[act] = group = Gtk.RadioButton()
|
|
|
247
|
+ self._activity_btns[act] = group = Gtk.RadioButton()
|
|
243
|
248
|
|
|
244
|
249
|
icon = Gtk.Image.new_from_icon_name(icon_name, Gtk.IconSize.MENU)
|
|
245
|
250
|
icon_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
|
| ... |
... |
@@ -249,11 +254,11 @@ class StatusChange(Gtk.ApplicationWindow, TimeoutWindow): |
|
249
|
254
|
label='<b>%s</b>' % ACTIVITIES[category]['category'])
|
|
250
|
255
|
label.set_use_markup(True)
|
|
251
|
256
|
icon_box.pack_start(label, False, False, 0)
|
|
252
|
|
- radio_btns[act].add(icon_box)
|
|
253
|
|
- radio_btns[act].join_group(self._ui.no_activity_button)
|
|
254
|
|
- radio_btns[act].connect(
|
|
|
257
|
+ self._activity_btns[act].add(icon_box)
|
|
|
258
|
+ self._activity_btns[act].join_group(self._ui.no_activity_button)
|
|
|
259
|
+ self._activity_btns[act].connect(
|
|
255
|
260
|
'toggled', self._on_activity_toggled, [category, 'other'])
|
|
256
|
|
- category_box.pack_start(radio_btns[act], False, False, 0)
|
|
|
261
|
+ category_box.pack_start(self._activity_btns[act], False, False, 0)
|
|
257
|
262
|
|
|
258
|
263
|
activities = list(ACTIVITIES[category].keys())
|
|
259
|
264
|
activities.sort()
|
| ... |
... |
@@ -264,10 +269,10 @@ class StatusChange(Gtk.ApplicationWindow, TimeoutWindow): |
|
264
|
269
|
act = category + '_' + activity
|
|
265
|
270
|
|
|
266
|
271
|
if group:
|
|
267
|
|
- radio_btns[act] = Gtk.RadioButton()
|
|
268
|
|
- radio_btns[act].join_group(group)
|
|
|
272
|
+ self._activity_btns[act] = Gtk.RadioButton()
|
|
|
273
|
+ self._activity_btns[act].join_group(group)
|
|
269
|
274
|
else:
|
|
270
|
|
- radio_btns[act] = group = Gtk.RadioButton()
|
|
|
275
|
+ self._activity_btns[act] = group = Gtk.RadioButton()
|
|
271
|
276
|
|
|
272
|
277
|
icon_name = get_activity_icon_name(category, activity)
|
|
273
|
278
|
icon = Gtk.Image.new_from_icon_name(
|
| ... |
... |
@@ -277,11 +282,13 @@ class StatusChange(Gtk.ApplicationWindow, TimeoutWindow): |
|
277
|
282
|
spacing=6)
|
|
278
|
283
|
icon_box.pack_start(icon, False, False, 0)
|
|
279
|
284
|
icon_box.pack_start(label, False, False, 0)
|
|
280
|
|
- radio_btns[act].join_group(self._ui.no_activity_button)
|
|
281
|
|
- radio_btns[act].connect('toggled', self._on_activity_toggled,
|
|
282
|
|
- [category, activity])
|
|
283
|
|
- radio_btns[act].add(icon_box)
|
|
284
|
|
- category_box.pack_start(radio_btns[act], False, False, 0)
|
|
|
285
|
+ self._activity_btns[act].join_group(
|
|
|
286
|
+ self._ui.no_activity_button)
|
|
|
287
|
+ self._activity_btns[act].connect(
|
|
|
288
|
+ 'toggled', self._on_activity_toggled, [category, activity])
|
|
|
289
|
+ self._activity_btns[act].add(icon_box)
|
|
|
290
|
+ category_box.pack_start(
|
|
|
291
|
+ self._activity_btns[act], False, False, 0)
|
|
285
|
292
|
|
|
286
|
293
|
if not self._pep_dict['activity']:
|
|
287
|
294
|
self._ui.no_activity_button.set_active(True)
|
| ... |
... |
@@ -291,8 +298,9 @@ class StatusChange(Gtk.ApplicationWindow, TimeoutWindow): |
|
291
|
298
|
self._pep_dict['activity']]:
|
|
292
|
299
|
self._pep_dict['subactivity'] = 'other'
|
|
293
|
300
|
|
|
294
|
|
- radio_btns[self._pep_dict['activity'] + '_' + self._pep_dict[
|
|
295
|
|
- 'subactivity']].set_active(True)
|
|
|
301
|
+ self._activity_btns[
|
|
|
302
|
+ self._pep_dict['activity'] + '_' + self._pep_dict[
|
|
|
303
|
+ 'subactivity']].set_active(True)
|
|
296
|
304
|
|
|
297
|
305
|
self._ui.activity_notebook.set_current_page(
|
|
298
|
306
|
ACTIVITY_PAGELIST.index(self._pep_dict['activity']))
|
| ... |
... |
@@ -309,6 +317,11 @@ class StatusChange(Gtk.ApplicationWindow, TimeoutWindow): |
|
309
|
317
|
self._ui.activity_button_label.set_text(
|
|
310
|
318
|
ACTIVITIES[self._pep_dict['activity']][
|
|
311
|
319
|
self._pep_dict['subactivity']])
|
|
|
320
|
+ self._activity_btns[
|
|
|
321
|
+ self._pep_dict['activity'] + '_' + self._pep_dict[
|
|
|
322
|
+ 'subactivity']].set_active(True)
|
|
|
323
|
+ self._ui.activity_notebook.set_current_page(
|
|
|
324
|
+ ACTIVITY_PAGELIST.index(self._pep_dict['activity']))
|
|
312
|
325
|
else:
|
|
313
|
326
|
icon_name = get_activity_icon_name(self._pep_dict['activity'])
|
|
314
|
327
|
self._ui.activity_image.set_from_icon_name(
|
| ... |
... |
@@ -326,7 +339,6 @@ class StatusChange(Gtk.ApplicationWindow, TimeoutWindow): |
|
326
|
339
|
|
|
327
|
340
|
x_position = 1
|
|
328
|
341
|
y_position = 0
|
|
329
|
|
- mood_buttons = {}
|
|
330
|
342
|
|
|
331
|
343
|
# Order them first
|
|
332
|
344
|
moods = []
|
| ... |
... |
@@ -337,16 +349,16 @@ class StatusChange(Gtk.ApplicationWindow, TimeoutWindow): |
|
337
|
349
|
for mood in moods:
|
|
338
|
350
|
image = Gtk.Image.new_from_icon_name(
|
|
339
|
351
|
'mood-%s' % mood, Gtk.IconSize.MENU)
|
|
340
|
|
- mood_buttons[mood] = Gtk.RadioButton()
|
|
341
|
|
- mood_buttons[mood].join_group(self._ui.no_mood_button)
|
|
342
|
|
- mood_buttons[mood].set_mode(False)
|
|
343
|
|
- mood_buttons[mood].add(image)
|
|
344
|
|
- mood_buttons[mood].set_relief(Gtk.ReliefStyle.NONE)
|
|
345
|
|
- mood_buttons[mood].set_tooltip_text(MOODS[mood])
|
|
346
|
|
- mood_buttons[mood].connect(
|
|
|
352
|
+ self._mood_btns[mood] = Gtk.RadioButton()
|
|
|
353
|
+ self._mood_btns[mood].join_group(self._ui.no_mood_button)
|
|
|
354
|
+ self._mood_btns[mood].set_mode(False)
|
|
|
355
|
+ self._mood_btns[mood].add(image)
|
|
|
356
|
+ self._mood_btns[mood].set_relief(Gtk.ReliefStyle.NONE)
|
|
|
357
|
+ self._mood_btns[mood].set_tooltip_text(MOODS[mood])
|
|
|
358
|
+ self._mood_btns[mood].connect(
|
|
347
|
359
|
'clicked', self._on_mood_button_clicked, mood)
|
|
348
|
360
|
self._ui.moods_grid.attach(
|
|
349
|
|
- mood_buttons[mood], x_position, y_position, 1, 1)
|
|
|
361
|
+ self._mood_btns[mood], x_position, y_position, 1, 1)
|
|
350
|
362
|
|
|
351
|
363
|
# Calculate the next position
|
|
352
|
364
|
x_position += 1
|
| ... |
... |
@@ -355,7 +367,7 @@ class StatusChange(Gtk.ApplicationWindow, TimeoutWindow): |
|
355
|
367
|
y_position += 1
|
|
356
|
368
|
|
|
357
|
369
|
if self._pep_dict['mood'] in MOODS:
|
|
358
|
|
- mood_buttons[self._pep_dict['mood']].set_active(True)
|
|
|
370
|
+ self._mood_btns[self._pep_dict['mood']].set_active(True)
|
|
359
|
371
|
self._ui.mood_label.set_text(MOODS[self._pep_dict['mood']])
|
|
360
|
372
|
else:
|
|
361
|
373
|
self._ui.mood_label.set_text(_('No mood selected'))
|
| ... |
... |
@@ -366,18 +378,21 @@ class StatusChange(Gtk.ApplicationWindow, TimeoutWindow): |
|
366
|
378
|
'mood-%s' % self._pep_dict['mood'], Gtk.IconSize.MENU)
|
|
367
|
379
|
self._ui.mood_button_label.set_text(
|
|
368
|
380
|
MOODS[self._pep_dict['mood']])
|
|
|
381
|
+ self._mood_btns[self._pep_dict['mood']].set_active(True)
|
|
|
382
|
+ self._ui.mood_label.set_text(MOODS[self._pep_dict['mood']])
|
|
369
|
383
|
else:
|
|
370
|
384
|
self._ui.mood_image.set_from_pixbuf(None)
|
|
371
|
385
|
self._ui.mood_button_label.set_text(_('No mood'))
|
|
|
386
|
+ self._ui.mood_label.set_text(_('No mood selected'))
|
|
372
|
387
|
|
|
373
|
388
|
def _on_preset_select(self, widget):
|
|
374
|
389
|
self.stop_timeout()
|
|
375
|
390
|
self._ui.preset_popover.popdown()
|
|
376
|
391
|
name = widget.get_name()
|
|
377
|
|
- self._message_buffer.set_text(self._preset_messages_dict[name][0])
|
|
378
|
|
- self._pep_dict['activity'] = self._preset_messages_dict[name][1]
|
|
379
|
|
- self._pep_dict['subactivity'] = self._preset_messages_dict[name][2]
|
|
380
|
|
- self._pep_dict['mood'] = self._preset_messages_dict[name][3]
|
|
|
392
|
+ self._message_buffer.set_text(self._presets[name][0])
|
|
|
393
|
+ self._pep_dict['activity'] = self._presets[name][1]
|
|
|
394
|
+ self._pep_dict['subactivity'] = self._presets[name][2]
|
|
|
395
|
+ self._pep_dict['mood'] = self._presets[name][3]
|
|
381
|
396
|
self._draw_activity()
|
|
382
|
397
|
self._draw_mood()
|
|
383
|
398
|
|
| ... |
... |
@@ -421,7 +436,7 @@ class StatusChange(Gtk.ApplicationWindow, TimeoutWindow): |
|
421
|
436
|
app.config.set_per('statusmsg', preset_name, 'mood', mood)
|
|
422
|
437
|
self._get_presets()
|
|
423
|
438
|
|
|
424
|
|
- if preset_name in self._preset_messages_dict:
|
|
|
439
|
+ if preset_name in self._presets:
|
|
425
|
440
|
NewConfirmationDialog(
|
|
426
|
441
|
_('Overwrite'),
|
|
427
|
442
|
_('Overwrite Status Message?'),
|