From 26f24fcd813c9bf80c3e32b6dd18870b0771bbec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Br=C3=B6tzmann?= Date: Mon, 15 Oct 2018 23:16:00 +0200 Subject: [PATCH] [triggers] Update GUI --- triggers/config_dialog.ui | 1538 ++++++++++++++++++++----------------- triggers/triggers.py | 80 +- 2 files changed, 861 insertions(+), 757 deletions(-) diff --git a/triggers/config_dialog.ui b/triggers/config_dialog.ui index dbfb817..6a331bb 100644 --- a/triggers/config_dialog.ui +++ b/triggers/config_dialog.ui @@ -1,5 +1,5 @@ - + @@ -9,16 +9,16 @@ - contact(s) + Contact(s) - group(s) + Group(s) - groupchat participant(s) + Groupchat participant(s) - everybody + Everybody @@ -44,35 +44,33 @@ False - 6 - Advanced Notifications Control - Advanced Notifications Control - False True - + + + + True False - 12 + 18 vertical - 12 + 6 - + True False vertical - 5 - + 90 True True - never in True True + horizontal @@ -82,197 +80,182 @@ False - False + True 0 - + True False - 1 - 212 + False + 1 - + + True + False + False + Up + Up + True + gtk-go-up + + + + False + True + + + + + True + False + False + Down + Down + True + gtk-go-down + + + + False + True + + + + True False - - - True - False - 10 - - - gtk-new - True - True - True - False - True - - - - False - False - 0 - - - - - gtk-go-up - True - True - True - False - True - - - - False - False - 1 - - - - - gtk-go-down - True - True - True - False - True - - - - False - False - 2 - - - - - gtk-delete - True - True - True - False - True - - - - False - False - 3 - - - - - True - False - 0 - - + New rule + New + True + gtk-new + + + False + True + + + + True + False + Delete rule + Delete + True + gtk-delete + + + + False + True + + + False - False + True 1 - True + False True 0 - + True False vertical 5 - - True - False - <b>Conditions</b> - True - - - False - False - 0 - - - - + True False + start vertical - 5 + 6 - + True False - 5 + 6 + Conditions + True + + + + False + False + 0 + + + + + True + False + center + 6 + 12 - + True False - When + end + Event True + - False - False - 0 + 0 + 0 + 200 True False liststore2 - + 0 - False - False - 1 + 1 + 0 - - - True - True - 0 - - - - - True - False - 5 - + True False - for + end + Category True + - False - False - 0 + 0 + 1 @@ -282,550 +265,354 @@ liststore1 - + 0 - False - True - 1 + 1 + 1 + 300 True + False True - True comma separated list - True - True - 2 + 2 + 1 + + + - True + False True 1 - - True - False - - - True - False - when I'm in - True - - - False - False - 0 - - - - - True - False - 3 - - - All statuses - True - True - False - True - True - - - - False - False - 0 - - - - - One or more special statuses... - True - True - False - True - True - all_status_rb - - - False - False - 1 - - - - - Online / Free For Chat - True - True - False - True - True - True - - - - False - False - 2 - - - - - Away - True - True - False - True - True - True - - - - False - False - 3 - - - - - Not Available - True - True - False - True - True - True - - - - False - False - 4 - - - - - Busy - True - True - False - True - True - True - - - - False - False - 5 - - - - - Invisible - True - True - False - True - True - True - - - - False - False - 6 - - - - - True - True - 1 - - - - - True - True - 2 - - - - - True - False - - - True - False - and I - True - - - False - False - 0 - - - - - Have - True - True - False - True - True - - - - False - False - 1 - - - - - Don't have - True - True - False - True - True - - - - False - False - 2 - - - - - True - False - a window/tab opened with that contact - True - - - False - False - 3 - - - - - True - True - 3 - - - - - True - False - False - - - True - False - and it - - - False - True - 0 - - - - - has - True - True - False - True - - - - False - True - 1 - - - - - doesn't have - True - True - False - True - - - - False - True - 2 - - - - - True - False - focus - - - False - True - 3 - - - - - True - True - 4 - - - - - True - True - 1 - - - - - True - False - <b>Actions</b> - True - - - False - False - 2 - - - - - True - False - 0 - none - - + True False + start + 6 6 - - _Inform me with a popup window + True - True - False - True - True - + False + start + My status + True + False - False + True 0 - - _Disable existing popup window + + All statuses True True False + start True True - + special_status_rb + False - False + True 1 - - - - - True - False - 0 - none - + + Certain status(es) True - False - 6 - 12 + True + False + start + True + True + all_status_rb + + + False + True + 2 + + + + + True + True + start + True - + True False vertical 6 - + + Online/Free For Chat True - False - 6 - True - - - Play a sound - True - True - False - True - True - - - - True - True - 0 - - - - - True - False - False - 6 - - - True - True - - - - True - True - 0 - - - - - ... - True - True - False - True - - - - False - False - 1 - - - - - True - True - False - - - - True - False - gtk-media-play - - - - - False - False - 2 - - - - - True - True - 1 - - + False + True + False + start + True + True + False - False + True 0 - - _Disable existing sound for this event + + Away True + False True False + start True True - + False - False + True 1 + + + Not Available + True + False + True + False + start + True + True + + + + False + True + 2 + + + + + Busy + True + False + True + False + start + True + True + + + + False + True + 3 + + + + + Invisible + True + False + True + False + start + True + True + + + + False + True + 4 + + + + + + + True + False + Status - - - - True - False - <b>Sounds</b> - True - + + False + True + 3 + + + False + True + 2 + + + + + True + False + 6 + 12 + + + True + False + end + Window/tab opened with contact + + + + 0 + 0 + + + + + True + False + end + Focus + + + + 0 + 1 + + + + + Opened + True + True + False + start + True + True + + + + 1 + 0 + + + + + Has focus + True + True + False + start + True + + + + 1 + 1 + + + + + Not opened + True + True + False + start + True + True + + + + 2 + 0 + + + + + Does not have focus + True + True + False + start + True + + + + 2 + 1 + + + + + False + True + 5 + - True + False True - 3 + 0 - + True False + vertical 6 - - _Open chat window with user + True - True - False - True - True - + False + 6 + Actions + True + False @@ -834,41 +621,322 @@ - - _Disable auto opening chat window + True - True - False - True - True - + False + 12 + + + True + False + vertical + 6 + + + True + False + start + Chat window + + + + False + True + 0 + + + + + _Open chat window with user + True + True + False + start + True + True + + + + False + True + 1 + + + + + _Disable automatically opening chat window + True + True + False + start + True + True + + + + False + True + 2 + + + + + False + True + 0 + + + + + True + False + vertical + 6 + + + True + False + start + Notifications + + + + False + True + 0 + + + + + _Inform me with a popup window + True + True + False + start + True + True + + + + False + True + 1 + + + + + _Disable existing popup window + True + True + False + start + True + True + + + + False + True + 2 + + + + + False + True + 1 + + False - False + True 1 + + + True + False + vertical + 6 + + + True + False + start + Sounds + True + + + + False + True + 0 + + + + + True + False + start + 12 + + + Play a sound + True + True + False + end + True + True + + + + False + True + 0 + + + + + True + False + False + start + 12 + + + 120 + True + True + + + + False + True + 0 + + + + + ... + True + True + False + True + + + + False + True + 1 + + + + + True + True + False + + + + True + False + gtk-media-play + + + + + False + True + 2 + + + + + False + True + 1 + + + + + False + False + 1 + + + + + _Disable existing sound for this event + True + True + False + start + True + True + + + + False + True + 2 + + + + + False + True + 2 + + - True + False True - 4 + 1 - + True True - True + 6 - + True False vertical - 5 + 6 - + + Delete this rule once it is applied + True + True + False + start + 6 + True + + + + False + True + 0 + + + + True False 6 @@ -890,13 +958,14 @@ + 200 True False True - True + False True 1 @@ -905,158 +974,193 @@ False False - 0 - - - - - True - False - 6 - - - _Show event in notification area - True - True - False - True - True - - - - False - False - 0 - - - - - _Disable showing event in notification area - True - True - False - True - True - - - - False - False - 1 - - - - - True - True 1 - + True False - 6 + 6 + 12 + + + True + False + start + Notification area + + + + 0 + 0 + + + + + True + False + start + Roster + + + + 1 + 0 + + - _Show event in roster + _Show event True True False + start True True - False - False - 0 + 1 + 1 - _Disable showing event in roster + _Disable showing event True True False + start True True - False - False - 1 + 1 + 2 + + + _Show event + True + True + False + start + True + True + + + + 0 + 1 + + + + + _Disable showing event + True + True + False + start + True + True + + + + 0 + 2 + + + + + False + True + start + Make window flash in taskbar + + + + 0 + 3 + + + + + _Activate UrgencyHint of window manager + True + False + True + start + True + True + + + + 0 + 4 + + + + + _Deactivate UrgencyHint of window manager + True + False + True + start + True + True + + + + 0 + 5 + + + + + + + + + + + - - True - True - 2 - - - - - Delete this rule once it's applied - True - True - False - True - - - - True - True - 3 - - - - - _Activate window manager's UrgencyHint to make chat window in taskbar flash - True - False - True - True - True - - False - False - 4 - - - - - _Deactivate window manager's UrgencyHint - True - False - True - True - True - - - - False - False - 5 + True + 7 - + True False Advanced Actions + - True + False True - 5 + 2 diff --git a/triggers/triggers.py b/triggers/triggers.py index 1d96e90..05535c5 100644 --- a/triggers/triggers.py +++ b/triggers/triggers.py @@ -56,7 +56,7 @@ except ImportError: class Triggers(GajimPlugin): @log_calls('TriggersPlugin') def init(self): - self.description = _('Configure Gajim\'s behaviour for each contact') + self.description = _('Configure Gajim\'s behaviour with conditions for each contact') self.config_dialog = TriggersPluginConfigDialog(self) self.config_default_values = {} @@ -297,22 +297,22 @@ class TriggersPluginConfigDialog(GajimPluginConfigDialog): self.xml = Gtk.Builder() self.xml.set_translation_domain('gajim_plugins') self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH, - ['vbox', 'liststore1', 'liststore2']) - vbox = self.xml.get_object('vbox') - self.get_child().pack_start(vbox, True, True, 0) + ['plugin_box', 'liststore1', 'liststore2']) + plugin_box = self.xml.get_object('plugin_box') + self.get_child().pack_start(plugin_box, True, True, 0) self.xml.connect_signals(self) self.connect('hide', self.on_hide) def on_run(self): # fill window - for w in ('conditions_treeview', 'config_vbox', 'event_combobox', + for w in ('conditions_treeview', 'config_box', 'event_combobox', 'recipient_type_combobox', 'recipient_list_entry', 'delete_button', - 'status_hbox', 'use_sound_cb', 'disable_sound_cb', 'use_popup_cb', + 'use_sound_cb', 'disable_sound_cb', 'use_popup_cb', 'disable_popup_cb', 'use_auto_open_cb', 'disable_auto_open_cb', 'use_systray_cb', 'disable_systray_cb', 'use_roster_cb', - 'disable_roster_cb', 'tab_opened_cb', 'not_tab_opened_cb', 'focus_hbox', - 'has_focus_cb', 'not_has_focus_cb', 'sound_entry', 'sound_file_hbox', + 'disable_roster_cb', 'tab_opened_cb', 'not_tab_opened_cb', + 'has_focus_cb', 'not_has_focus_cb', 'sound_entry', 'sound_file_box', 'up_button', 'down_button', 'run_command_cb', 'command_entry', 'one_shot_cb', 'use_urgency_hint_cb', 'disable_urgency_hint_cb'): self.__dict__[w] = self.xml.get_object(w) @@ -322,15 +322,13 @@ class TriggersPluginConfigDialog(GajimPluginConfigDialog): self.config[int(n)] = self.plugin.config[n] # Contains status checkboxes - childs = self.status_hbox.get_children() - - self.all_status_rb = childs[0] - self.special_status_rb = childs[1] - self.online_cb = childs[2] - self.away_cb = childs[3] - self.xa_cb = childs[4] - self.dnd_cb = childs[5] - self.invisible_cb = childs[6] + self.all_status_rb = self.xml.get_object('all_status_rb') + self.special_status_rb = self.xml.get_object('special_status_rb') + self.online_cb = self.xml.get_object('online_cb') + self.away_cb = self.xml.get_object('away_cb') + self.xa_cb = self.xml.get_object('xa_cb') + self.dnd_cb = self.xml.get_object('dnd_cb') + self.invisible_cb = self.xml.get_object('invisible_cb') if not self.conditions_treeview.get_column(0): # window never opened @@ -369,7 +367,7 @@ class TriggersPluginConfigDialog(GajimPluginConfigDialog): # No rule selected at init time self.conditions_treeview.get_selection().unselect_all() self.active_num = -1 - self.config_vbox.set_sensitive(False) + self.config_box.set_sensitive(False) self.delete_button.set_sensitive(False) self.down_button.set_sensitive(False) self.up_button.set_sensitive(False) @@ -411,6 +409,7 @@ class TriggersPluginConfigDialog(GajimPluginConfigDialog): self.__dict__[v + '_cb'].set_active(True) else: self.__dict__[v + '_cb'].set_active(False) + self.on_status_radiobutton_toggled(self.all_status_rb) # tab_opened @@ -483,12 +482,12 @@ class TriggersPluginConfigDialog(GajimPluginConfigDialog): if self.all_status_rb.get_active(): status = '' else: - status = _('when I am ') + status = _('and I am: ') for st in ('online', 'away', 'xa', 'dnd', 'invisible'): if self.__dict__[st + '_cb'].get_active(): - status += helpers.get_uf_show(st) + ' ' - model[iter_][1] = "When %s for %s %s %s" % (event, recipient_type, - recipient, status) + status += helpers.get_uf_show(st) + ', ' + model[iter_][1] = _("When event: %s for category: %s %s %s") % (event, + recipient_type, recipient, status) def on_conditions_treeview_cursor_changed(self, widget): (model, iter_) = widget.get_selection().get_selected() @@ -496,23 +495,23 @@ class TriggersPluginConfigDialog(GajimPluginConfigDialog): self.active_num = '' return self.active_num = model[iter_][0] - if self.active_num == '0': + if self.active_num == 0: self.up_button.set_sensitive(False) else: self.up_button.set_sensitive(True) - max = self.conditions_treeview.get_model().iter_n_children(None) - if self.active_num == max - 1: + _max = self.conditions_treeview.get_model().iter_n_children(None) + if self.active_num == _max - 1: self.down_button.set_sensitive(False) else: self.down_button.set_sensitive(True) self.initiate_rule_state() - self.config_vbox.set_sensitive(True) + self.config_box.set_sensitive(True) self.delete_button.set_sensitive(True) def on_new_button_clicked(self, widget): model = self.conditions_treeview.get_model() num = self.conditions_treeview.get_model().iter_n_children(None) - self.config[num] = {'event': '', 'recipient_type': 'all', + self.config[num] = {'event': 'message_received', 'recipient_type': 'all', 'recipients': '', 'status': 'all', 'tab_opened': 'both', 'has_focus': 'both', 'sound': '', 'sound_file': '', 'popup': '', 'auto_open': '', 'run_command': False, 'command': '', 'systray': '', @@ -522,7 +521,7 @@ class TriggersPluginConfigDialog(GajimPluginConfigDialog): self.conditions_treeview.set_cursor(path) self.active_num = num self.set_treeview_string() - self.config_vbox.set_sensitive(True) + self.config_box.set_sensitive(True) def on_delete_button_clicked(self, widget): (model, iter_) = self.conditions_treeview.get_selection().get_selected() @@ -539,7 +538,7 @@ class TriggersPluginConfigDialog(GajimPluginConfigDialog): model.remove(iter_) del self.config[num] self.active_num = '' - self.config_vbox.set_sensitive(False) + self.config_box.set_sensitive(False) self.delete_button.set_sensitive(False) self.up_button.set_sensitive(False) self.down_button.set_sensitive(False) @@ -596,9 +595,9 @@ class TriggersPluginConfigDialog(GajimPluginConfigDialog): self.recipient_type_combobox.get_active()] self.config[self.active_num]['recipient_type'] = recipient_type if recipient_type == 'all': - self.recipient_list_entry.hide() + self.recipient_list_entry.set_sensitive(False) else: - self.recipient_list_entry.show() + self.recipient_list_entry.set_sensitive(True) self.set_treeview_string() def on_recipient_list_entry_changed(self, widget): @@ -625,19 +624,18 @@ class TriggersPluginConfigDialog(GajimPluginConfigDialog): if self.active_num < 0: return if self.all_status_rb.get_active(): + self.xml.get_object('status_expander').set_expanded(False) self.config[self.active_num]['status'] = 'all' # 'All status' clicked for st in ('online', 'away', 'xa', 'dnd', 'invisible'): - self.__dict__[st + '_cb'].hide() - - self.special_status_rb.show() + self.__dict__[st + '_cb'].set_sensitive(False) else: + self.xml.get_object('status_expander').set_expanded(True) self.set_status_config() # 'special status' clicked for st in ('online', 'away', 'xa', 'dnd', 'invisible'): - self.__dict__[st + '_cb'].show() + self.__dict__[st + '_cb'].set_sensitive(True) - self.special_status_rb.hide() self.set_treeview_string() def on_status_cb_toggled(self, widget): @@ -650,13 +648,15 @@ class TriggersPluginConfigDialog(GajimPluginConfigDialog): if self.active_num < 0: return if self.tab_opened_cb.get_active(): - self.focus_hbox.set_sensitive(True) + self.has_focus_cb.set_sensitive(True) + self.not_has_focus_cb.set_sensitive(True) if self.not_tab_opened_cb.get_active(): self.config[self.active_num]['tab_opened'] = 'both' else: self.config[self.active_num]['tab_opened'] = 'yes' else: - self.focus_hbox.set_sensitive(False) + self.has_focus_cb.set_sensitive(False) + self.not_has_focus_cb.set_sensitive(False) self.not_tab_opened_cb.set_active(True) self.config[self.active_num]['tab_opened'] = 'no' @@ -720,9 +720,9 @@ class TriggersPluginConfigDialog(GajimPluginConfigDialog): def on_use_sound_cb_toggled(self, widget): self.on_use_it_toggled(widget, self.disable_sound_cb, 'sound') if widget.get_active(): - self.sound_file_hbox.set_sensitive(True) + self.sound_file_box.set_sensitive(True) else: - self.sound_file_hbox.set_sensitive(False) + self.sound_file_box.set_sensitive(False) def on_browse_for_sounds_button_clicked(self, widget, data=None): if NEW_FILECHOOSER: