Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim-plugins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Brötzmann <mailtrash@posteo.de>2020-05-06 10:06:58 +0300
committerDaniel Brötzmann <mailtrash@posteo.de>2020-05-06 10:09:04 +0300
commit3624bf9d61dc0700370b0b8c9bea050626716db4 (patch)
tree993b74524e96ab4389654549acc9ec920878f152 /triggers
parentfcba4c8b0708a8fc01382e777b04e659e4998117 (diff)
[triggers] Refactor plugin
- Use new config dialog - Add scrolledwindow in order to reduce dialog height - Fix pylint errors
Diffstat (limited to 'triggers')
-rw-r--r--triggers/config_dialog.ui1149
-rw-r--r--triggers/gtk/config.py590
-rw-r--r--triggers/gtk/config.ui1108
-rw-r--r--triggers/triggers.py663
4 files changed, 1760 insertions, 1750 deletions
diff --git a/triggers/config_dialog.ui b/triggers/config_dialog.ui
deleted file mode 100644
index f848c49..0000000
--- a/triggers/config_dialog.ui
+++ /dev/null
@@ -1,1149 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.22.2 -->
-<interface>
- <requires lib="gtk+" version="3.20"/>
- <object class="GtkListStore" id="liststore1">
- <columns>
- <!-- column-name item -->
- <column type="gchararray"/>
- </columns>
- <data>
- <row>
- <col id="0" translatable="yes">Contact(s)</col>
- </row>
- <row>
- <col id="0" translatable="yes">Group(s)</col>
- </row>
- <row>
- <col id="0" translatable="yes">Groupchat participant(s)</col>
- </row>
- <row>
- <col id="0" translatable="yes">Everybody</col>
- </row>
- </data>
- </object>
- <object class="GtkListStore" id="liststore2">
- <columns>
- <!-- column-name item -->
- <column type="gchararray"/>
- </columns>
- <data>
- <row>
- <col id="0" translatable="yes">Receive a Message</col>
- </row>
- <row>
- <col id="0" translatable="yes">Contact Connects</col>
- </row>
- <row>
- <col id="0" translatable="yes">Contact Disconnects</col>
- </row>
- <row>
- <col id="0" translatable="yes">Contact Changes Status</col>
- </row>
- </data>
- </object>
- <object class="GtkBox" id="plugin_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">18</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkBox" id="rules_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkScrolledWindow">
- <property name="height_request">90</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="GtkTreeView" id="conditions_treeview">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="enable_grid_lines">horizontal</property>
- <signal name="cursor-changed" handler="on_conditions_treeview_cursor_changed" swapped="no"/>
- <child internal-child="selection">
- <object class="GtkTreeSelection"/>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolbar">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="show_arrow">False</property>
- <property name="icon_size">1</property>
- <child>
- <object class="GtkToolButton" id="up_button">
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">False</property>
- <property name="tooltip_text" translatable="yes">Up</property>
- <property name="label" translatable="yes">Up</property>
- <property name="use_underline">True</property>
- <property name="stock_id">gtk-go-up</property>
- <signal name="clicked" handler="on_up_button_clicked" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="down_button">
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">False</property>
- <property name="tooltip_text" translatable="yes">Down</property>
- <property name="label" translatable="yes">Down</property>
- <property name="use_underline">True</property>
- <property name="stock_id">gtk-go-down</property>
- <signal name="clicked" handler="on_down_button_clicked" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="new_button">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="tooltip_text" translatable="yes">New rule</property>
- <property name="label" translatable="yes">New rule</property>
- <property name="use_underline">True</property>
- <property name="stock_id">gtk-new</property>
- <signal name="clicked" handler="on_new_button_clicked" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="delete_button">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="tooltip_text" translatable="yes">Delete rule</property>
- <property name="label" translatable="yes">Delete rule</property>
- <property name="use_underline">True</property>
- <property name="stock_id">gtk-delete</property>
- <signal name="clicked" handler="on_delete_button_clicked" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <style>
- <class name="inline-toolbar"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="config_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">5</property>
- <child>
- <object class="GtkBox" id="conditions_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_top">6</property>
- <property name="label" translatable="yes">Conditions</property>
- <property name="use_markup">True</property>
- <style>
- <class name="large-header"/>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkGrid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="row_spacing">6</property>
- <property name="column_spacing">12</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">end</property>
- <property name="label" translatable="yes">Event</property>
- <property name="use_markup">True</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="event_combobox">
- <property name="width_request">200</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="model">liststore2</property>
- <signal name="changed" handler="on_event_combobox_changed" swapped="no"/>
- <child>
- <object class="GtkCellRendererText"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">end</property>
- <property name="label" translatable="yes">Category</property>
- <property name="use_markup">True</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="recipient_type_combobox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="model">liststore1</property>
- <signal name="changed" handler="on_recipient_type_combobox_changed" swapped="no"/>
- <child>
- <object class="GtkCellRendererText"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="recipient_list_entry">
- <property name="width_request">300</property>
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="tooltip_text" translatable="yes">comma separated list</property>
- <signal name="changed" handler="on_recipient_list_entry_changed" swapped="no"/>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="status_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="margin_top">6</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="valign">start</property>
- <property name="label" translatable="yes">My status</property>
- <property name="use_markup">True</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkRadioButton" id="all_status_rb">
- <property name="label" translatable="yes">All statuses</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="valign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <property name="group">special_status_rb</property>
- <signal name="toggled" handler="on_status_radiobutton_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkRadioButton" id="special_status_rb">
- <property name="label" translatable="yes">Certain status(es)</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="valign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <property name="group">all_status_rb</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkExpander" id="status_expander">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="valign">start</property>
- <property name="expanded">True</property>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkCheckButton" id="online_cb">
- <property name="label" translatable="yes">Online/Free For Chat</property>
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_status_cb_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="away_cb">
- <property name="label" translatable="yes">Away</property>
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_status_cb_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="xa_cb">
- <property name="label" translatable="yes">Not Available</property>
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_status_cb_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="dnd_cb">
- <property name="label" translatable="yes">Busy</property>
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_status_cb_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Status</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">3</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkGrid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="row_spacing">6</property>
- <property name="column_spacing">12</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">end</property>
- <property name="label" translatable="yes">Window/tab opened with contact</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">end</property>
- <property name="label" translatable="yes">Focus</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="tab_opened_cb">
- <property name="label" translatable="yes">Opened</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_tab_opened_cb_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="has_focus_cb">
- <property name="label" translatable="yes">Has focus</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_has_focus_cb_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="not_tab_opened_cb">
- <property name="label" translatable="yes">Not opened</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_not_tab_opened_cb_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="not_has_focus_cb">
- <property name="label" translatable="yes">Does not have focus</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_not_has_focus_cb_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">5</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="actions_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_top">6</property>
- <property name="label" translatable="yes">Actions</property>
- <property name="use_markup">True</property>
- <style>
- <class name="large-header"/>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkBox" id="chat_window_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="label" translatable="yes">Chat window</property>
- <style>
- <class name="bold"/>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="use_auto_open_cb">
- <property name="label" translatable="yes">_Open chat window with user</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_use_auto_open_cb_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="disable_auto_open_cb">
- <property name="label" translatable="yes">_Disable automatically opening chat window</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_disable_auto_open_cb_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="notifications_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="label" translatable="yes">Notifications</property>
- <style>
- <class name="bold"/>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="use_popup_cb">
- <property name="label" translatable="yes">_Inform me with a popup window</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_use_popup_cb_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="disable_popup_cb">
- <property name="label" translatable="yes">_Disable existing popup window</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_disable_popup_cb_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="sounds_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="label" translatable="yes">Sounds</property>
- <property name="use_markup">True</property>
- <style>
- <class name="bold"/>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkCheckButton" id="use_sound_cb">
- <property name="label" translatable="yes">Play a sound</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">end</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_use_sound_cb_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="sound_file_box">
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkEntry" id="sound_entry">
- <property name="width_request">120</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <signal name="changed" handler="on_sound_entry_changed" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton">
- <property name="label">...</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <signal name="clicked" handler="on_browse_for_sounds_button_clicked" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="play_button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <signal name="clicked" handler="on_play_button_clicked" swapped="no"/>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-media-play</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="disable_sound_cb">
- <property name="label" translatable="yes">_Disable existing sound for this event</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_disable_sound_cb_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkExpander" id="advanced_expander">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="margin_top">6</property>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkCheckButton" id="one_shot_cb">
- <property name="label" translatable="yes">Delete this rule once it is applied</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="margin_top">6</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_one_shot_cb_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkCheckButton" id="run_command_cb">
- <property name="label" translatable="yes">Launch a command</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_run_command_cb_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="command_entry">
- <property name="width_request">200</property>
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <signal name="changed" handler="on_command_entry_changed" swapped="no"/>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkGrid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="row_spacing">6</property>
- <property name="column_spacing">12</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="label" translatable="yes">Notification area</property>
- <style>
- <class name="bold"/>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="label" translatable="yes">Roster</property>
- <style>
- <class name="bold"/>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="use_roster_cb">
- <property name="label" translatable="yes">_Show event</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_use_roster_cb_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="disable_roster_cb">
- <property name="label" translatable="yes">_Disable showing event</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_disable_roster_cb_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="use_systray_cb">
- <property name="label" translatable="yes">_Show event</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_use_systray_cb_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="disable_systray_cb">
- <property name="label" translatable="yes">_Disable showing event</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_disable_systray_cb_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="urgency_hint_label">
- <property name="can_focus">False</property>
- <property name="no_show_all">True</property>
- <property name="halign">start</property>
- <property name="label" translatable="yes">Make window flash in taskbar</property>
- <style>
- <class name="bold"/>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="use_urgency_hint_cb">
- <property name="label" translatable="yes">_Activate UrgencyHint of window manager</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="no_show_all">True</property>
- <property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_use_urgency_hint_cb_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">4</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="disable_urgency_hint_cb">
- <property name="label" translatable="yes">_Deactivate UrgencyHint of window manager</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="no_show_all">True</property>
- <property name="halign">start</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_disable_urgency_hint_cb_toggled" swapped="no"/>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">5</property>
- </packing>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">7</property>
- </packing>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Advanced Actions</property>
- <style>
- <class name="bold"/>
- <class name="dim-label"/>
- </style>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
-</interface>
diff --git a/triggers/gtk/config.py b/triggers/gtk/config.py
new file mode 100644
index 0000000..d64f809
--- /dev/null
+++ b/triggers/gtk/config.py
@@ -0,0 +1,590 @@
+# Copyright (C) 2018 Philipp Hörist <philipp AT hoerist.com>
+#
+# This file is part of Gajim.
+#
+# Gajim 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; version 3 only.
+#
+# Gajim 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 Gajim. If not, see <http://www.gnu.org/licenses/>.
+
+from pathlib import Path
+
+from gi.repository import Gtk
+from gi.repository import Gdk
+
+from gajim.common import app
+from gajim.common.helpers import get_uf_show
+from gajim.common.helpers import play_sound_file
+
+from gajim.plugins.plugins_i18n import _
+from gajim.plugins.helpers import get_builder
+
+EVENTS = {
+ 'message_received': [],
+ 'contact_connected': [
+ 'use_systray_cb',
+ 'disable_systray_cb',
+ 'use_roster_cb',
+ 'disable_roster_cb'
+ ],
+ 'contact_disconnected': [
+ 'use_systray_cb',
+ 'disable_systray_cb',
+ 'use_roster_cb',
+ 'disable_roster_cb'
+ ],
+ 'contact_status_change': [
+ 'use_systray_cb',
+ 'disable_systray_cb',
+ 'use_roster_cb',
+ 'disable_roster_cb'
+ ]
+}
+
+RECIPIENT_TYPES = [
+ 'contact',
+ 'group',
+ 'groupchat',
+ 'all'
+]
+
+
+class ConfigDialog(Gtk.ApplicationWindow):
+ def __init__(self, plugin, transient):
+ Gtk.ApplicationWindow.__init__(self)
+ self.set_application(app.app)
+ self.set_show_menubar(False)
+ self.set_title(_('Triggers Configuration'))
+ self.set_transient_for(transient)
+ self.set_default_size(600, 700)
+ self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
+ self.set_modal(True)
+ self.set_destroy_with_parent(True)
+
+ ui_path = Path(__file__).parent
+ self._ui = get_builder(ui_path.resolve() / 'config.ui')
+
+ self._plugin = plugin
+
+ self.add(self._ui.box)
+ self.show_all()
+
+ self._active_num = ''
+ self._initialize()
+
+ self._ui.connect_signals(self)
+ self.connect('destroy', self._on_destroy)
+
+ def _on_destroy(self, *args):
+ for num in list(self._plugin.config.keys()):
+ del self._plugin.config[num]
+ for num in self._config:
+ self._plugin.config[str(num)] = self._config[num]
+
+ def _initialize(self):
+ # Fill window
+ for widget in (
+ 'conditions_treeview', 'config_box', 'event_combobox',
+ 'recipient_type_combobox', 'recipient_list_entry',
+ 'delete_button', 'online_cb', 'away_cb', 'xa_cb', 'dnd_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', 'has_focus_cb',
+ 'not_has_focus_cb', 'filechooser', 'sound_file_box',
+ 'up_button', 'down_button', 'run_command_cb',
+ 'command_entry', 'one_shot_cb'):
+ self._ui.__dict__[widget] = self._ui.get_object(widget)
+
+ self._config = {}
+ for num in self._plugin.config:
+ self._config[int(num)] = self._plugin.config[num]
+
+ if not self._ui.conditions_treeview.get_column(0):
+ # Window never opened
+ model = Gtk.ListStore(int, str)
+ model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
+ self._ui.conditions_treeview.set_model(model)
+
+ # '#' Means number
+ col = Gtk.TreeViewColumn(_('#'))
+ self._ui.conditions_treeview.append_column(col)
+ renderer = Gtk.CellRendererText()
+ col.pack_start(renderer, expand=False)
+ col.add_attribute(renderer, 'text', 0)
+
+ col = Gtk.TreeViewColumn(_('Condition'))
+ self._ui.conditions_treeview.append_column(col)
+ renderer = Gtk.CellRendererText()
+ col.pack_start(renderer, expand=True)
+ col.add_attribute(renderer, 'text', 1)
+ else:
+ model = self._ui.conditions_treeview.get_model()
+
+ model.clear()
+
+ # Fill conditions_treeview
+ num = 0
+ while num in self._config:
+ iter_ = model.append((num, ''))
+ path = model.get_path(iter_)
+ self._ui.conditions_treeview.set_cursor(path)
+ self._active_num = num
+ self._initiate_rule_state()
+ self._set_treeview_string()
+ num += 1
+
+ # No rule selected at init time
+ self._ui.conditions_treeview.get_selection().unselect_all()
+ self._active_num = -1
+ self._ui.config_box.set_sensitive(False)
+ self._ui.delete_button.set_sensitive(False)
+ self._ui.down_button.set_sensitive(False)
+ self._ui.up_button.set_sensitive(False)
+
+ filter_ = Gtk.FileFilter()
+ filter_.set_name(_('All Files'))
+ filter_.add_pattern('*')
+ self._ui.filechooser.add_filter(filter_)
+
+ filter_ = Gtk.FileFilter()
+ filter_.set_name(_('Wav Sounds'))
+ filter_.add_pattern('*.wav')
+ self._ui.filechooser.add_filter(filter_)
+ self._ui.filechooser.set_filter(filter_)
+
+ def _initiate_rule_state(self):
+ """
+ Set values for all widgets
+ """
+ if self._active_num < 0:
+ return
+
+ # event
+ value = self._config[self._active_num]['event']
+ if value:
+ self._ui.event_combobox.set_active(
+ list(EVENTS.keys()).index(value))
+ else:
+ self._ui.event_combobox.set_active(-1)
+
+ # recipient_type
+ value = self._config[self._active_num]['recipient_type']
+ if value:
+ self._ui.recipient_type_combobox.set_active(
+ RECIPIENT_TYPES.index(value))
+ else:
+ self._ui.recipient_type_combobox.set_active(-1)
+
+ # recipient
+ value = self._config[self._active_num]['recipients']
+ if not value:
+ value = ''
+ self._ui.recipient_list_entry.set_text(value)
+
+ # status
+ value = self._config[self._active_num]['status']
+ if value == 'all':
+ self._ui.all_status_rb.set_active(True)
+ else:
+ self._ui.special_status_rb.set_active(True)
+ values = value.split()
+ for val in ('online', 'away', 'xa', 'dnd'):
+ if val in values:
+ self._ui.__dict__[val + '_cb'].set_active(True)
+ else:
+ self._ui.__dict__[val + '_cb'].set_active(False)
+
+ self._on_status_radiobutton_toggled(self._ui.all_status_rb)
+
+ # tab_opened
+ value = self._config[self._active_num]['tab_opened']
+ self._ui.tab_opened_cb.set_active(True)
+ self._ui.not_tab_opened_cb.set_active(True)
+ if value == 'no':
+ self._ui.tab_opened_cb.set_active(False)
+ elif value == 'yes':
+ self._ui.not_tab_opened_cb.set_active(False)
+
+ # has_focus
+ if 'has_focus' not in self._config[self._active_num]:
+ self._config[self._active_num]['has_focus'] = 'both'
+ value = self._config[self._active_num]['has_focus']
+ self._ui.has_focus_cb.set_active(True)
+ self._ui.not_has_focus_cb.set_active(True)
+ if value == 'no':
+ self._ui.has_focus_cb.set_active(False)
+ elif value == 'yes':
+ self._ui.not_has_focus_cb.set_active(False)
+
+ # sound_file
+ value = self._config[self._active_num]['sound_file']
+ if value is None:
+ self._ui.filechooser.unselect_all()
+ else:
+ self._ui.filechooser.set_filename(value)
+
+ # sound, popup, auto_open, systray, roster
+ for option in ('sound', 'popup', 'auto_open', 'systray', 'roster'):
+ value = self._config[self._active_num][option]
+ if value == 'yes':
+ self._ui.__dict__['use_' + option + '_cb'].set_active(True)
+ else:
+ self._ui.__dict__['use_' + option + '_cb'].set_active(False)
+ if value == 'no':
+ self._ui.__dict__['disable_' + option + '_cb'].set_active(True)
+ else:
+ self._ui.__dict__['disable_' + option + '_cb'].set_active(False)
+
+ # run_command
+ value = self._config[self._active_num]['run_command']
+ self._ui.run_command_cb.set_active(value)
+
+ # command
+ value = self._config[self._active_num]['command']
+ self._ui.command_entry.set_text(value)
+
+ # one shot
+ if 'one_shot' in self._config[self._active_num]:
+ value = self._config[self._active_num]['one_shot']
+ else:
+ value = False
+ self._ui.one_shot_cb.set_active(value)
+
+ def _set_treeview_string(self):
+ selection = self._ui.conditions_treeview.get_selection()
+ (model, iter_) = selection.get_selected()
+ if not iter_:
+ return
+ ind = self._ui.event_combobox.get_active()
+ event = ''
+ if ind > -1:
+ event = self._ui.event_combobox.get_model()[ind][0]
+ ind = self._ui.recipient_type_combobox.get_active()
+ recipient_type = ''
+ if ind > -1:
+ recipient_type_model = self._ui.recipient_type_combobox.get_model()
+ recipient_type = recipient_type_model[ind][0]
+ recipient = ''
+ if recipient_type != 'everybody':
+ recipient = self._ui.recipient_list_entry.get_text()
+ if self._ui.all_status_rb.get_active():
+ status = ''
+ else:
+ status = _('and I am ')
+ for st in ('online', 'away', 'xa', 'dnd'):
+ if self._ui.__dict__[st + '_cb'].get_active():
+ status += get_uf_show(st) + ' '
+ model[iter_][1] = _('%(event)s (%(recipient_type)s) %(recipient)s '
+ '%(status)s') % {
+ 'event': event,
+ 'recipient_type': recipient_type,
+ 'recipient': recipient,
+ 'status': status}
+
+ def _on_conditions_treeview_cursor_changed(self, widget):
+ (model, iter_) = widget.get_selection().get_selected()
+ if not iter_:
+ self._active_num = ''
+ return
+ self._active_num = model[iter_][0]
+ if self._active_num == 0:
+ self._ui.up_button.set_sensitive(False)
+ else:
+ self._ui.up_button.set_sensitive(True)
+ _max = widget.get_model().iter_n_children(None)
+ if self._active_num == _max - 1:
+ self._ui.down_button.set_sensitive(False)
+ else:
+ self._ui.down_button.set_sensitive(True)
+ self._initiate_rule_state()
+ self._ui.config_box.set_sensitive(True)
+ self._ui.delete_button.set_sensitive(True)
+
+ def _on_new_button_clicked(self, _widget):
+ model = self._ui.conditions_treeview.get_model()
+ num = self._ui.conditions_treeview.get_model().iter_n_children(None)
+ 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': '',
+ 'roster': '',
+ 'one_shot': False,
+ }
+ iter_ = model.append((num, ''))
+ path = model.get_path(iter_)
+ self._ui.conditions_treeview.set_cursor(path)
+ self._active_num = num
+ self._set_treeview_string()
+ self._ui.config_box.set_sensitive(True)
+
+ def _on_delete_button_clicked(self, widget):
+ selection = self._ui.conditions_treeview.get_selection()
+ (model, iter_) = selection.get_selected()
+ if not iter_:
+ return
+ # up all others
+ iter2 = model.iter_next(iter_)
+ num = self._active_num
+ while iter2:
+ num = model[iter2][0]
+ model[iter2][0] = num - 1
+ self._config[num - 1] = self._config[num].copy()
+ iter2 = model.iter_next(iter2)
+ model.remove(iter_)
+ del self._config[num]
+ self._active_num = ''
+ widget.set_sensitive(False)
+ self._ui.up_button.set_sensitive(False)
+ self._ui.down_button.set_sensitive(False)
+ self._ui.config_box.set_sensitive(False)
+
+ def _on_up_button_clicked(self, _widget):
+ selection = self._ui.conditions_treeview.get_selection()
+ (model, iter_) = selection.get_selected()
+ if not iter_:
+ return
+ conf = self._config[self._active_num].copy()
+ self._config[self._active_num] = self._config[self._active_num - 1]
+ self._config[self._active_num - 1] = conf
+
+ model[iter_][0] = self._active_num - 1
+ # get previous iter
+ path = model.get_path(iter_)
+ iter_ = model.get_iter((path[0] - 1,))
+ model[iter_][0] = self._active_num
+ self._on_conditions_treeview_cursor_changed(
+ self._ui.conditions_treeview)
+
+ def _on_down_button_clicked(self, _widget):
+ selection = self._ui.conditions_treeview.get_selection()
+ (model, iter_) = selection.get_selected()
+ if not iter_:
+ return
+ conf = self._config[self._active_num].copy()
+ self._config[self._active_num] = self._config[self._active_num + 1]
+ self._config[self._active_num + 1] = conf
+
+ model[iter_][0] = self._active_num + 1
+ iter_ = model.iter_next(iter_)
+ model[iter_][0] = self._active_num
+ self._on_conditions_treeview_cursor_changed(
+ self._ui.conditions_treeview)
+
+ def _on_event_combobox_changed(self, widget):
+ if self._active_num < 0:
+ return
+ active = widget.get_active()
+ if active == -1:
+ return
+ event = list(EVENTS.keys())[active]
+ self._config[self._active_num]['event'] = event
+ for widget in ('use_systray_cb', 'disable_systray_cb', 'use_roster_cb',
+ 'disable_roster_cb'):
+ self._ui.__dict__[widget].set_sensitive(True)
+ for widget in EVENTS[event]:
+ self._ui.__dict__[widget].set_sensitive(False)
+ self._ui.__dict__[widget].set_state(False)
+ self._set_treeview_string()
+
+ def _on_recipient_type_combobox_changed(self, widget):
+ if self._active_num < 0:
+ return
+ recipient_type = RECIPIENT_TYPES[widget.get_active()]
+ self._config[self._active_num]['recipient_type'] = recipient_type
+ if recipient_type == 'all':
+ self._ui.recipient_list_entry.set_sensitive(False)
+ else:
+ self._ui.recipient_list_entry.set_sensitive(True)
+ self._set_treeview_string()
+
+ def _on_recipient_list_entry_changed(self, widget):
+ if self._active_num < 0:
+ return
+ recipients = widget.get_text()
+ # TODO: do some check
+ self._config[self._active_num]['recipients'] = recipients
+ self._set_treeview_string()
+
+ def _set_status_config(self):
+ if self._active_num < 0:
+ return
+ status = ''
+ for st in ('online', 'away', 'xa', 'dnd'):
+ if self._ui.__dict__[st + '_cb'].get_active():
+ status += st + ' '
+ if status:
+ status = status[:-1]
+ self._config[self._active_num]['status'] = status
+ self._set_treeview_string()
+
+ def _on_status_radiobutton_toggled(self, _widget):
+ if self._active_num < 0:
+ return
+ if self._ui.all_status_rb.get_active():
+ self._ui.status_expander.set_expanded(False)
+ self._config[self._active_num]['status'] = 'all'
+ # 'All status' clicked
+ for st in ('online', 'away', 'xa', 'dnd'):
+ self._ui.__dict__[st + '_cb'].set_sensitive(False)
+ else:
+ self._ui.status_expander.set_expanded(True)
+ self._set_status_config()
+ # 'special status' clicked
+ for st in ('online', 'away', 'xa', 'dnd'):
+ self._ui.__dict__[st + '_cb'].set_sensitive(True)
+
+ self._set_treeview_string()
+
+ def _on_status_cb_toggled(self, _widget):
+ if self._active_num < 0:
+ return
+ self._set_status_config()
+
+ # tab_opened OR (not xor) not_tab_opened must be active
+ def _on_tab_opened_cb_toggled(self, widget):
+ if self._active_num < 0:
+ return
+ if widget.get_active():
+ self._ui.has_focus_cb.set_sensitive(True)
+ self._ui.not_has_focus_cb.set_sensitive(True)
+ if self._ui.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._ui.has_focus_cb.set_sensitive(False)
+ self._ui.not_has_focus_cb.set_sensitive(False)
+ self._ui.not_tab_opened_cb.set_active(True)
+ self._config[self._active_num]['tab_opened'] = 'no'
+
+ def _on_not_tab_opened_cb_toggled(self, widget):
+ if self._active_num < 0:
+ return
+ if widget.get_active():
+ if self._ui.tab_opened_cb.get_active():
+ self._config[self._active_num]['tab_opened'] = 'both'
+ else:
+ self._config[self._active_num]['tab_opened'] = 'no'
+ else:
+ self._ui.tab_opened_cb.set_active(True)
+ self._config[self._active_num]['tab_opened'] = 'yes'
+
+ # has_focus OR (not xor) not_has_focus must be active
+ def _on_has_focus_cb_toggled(self, widget):
+ if self._active_num < 0:
+ return
+ if widget.get_active():
+ if self._ui.not_has_focus_cb.get_active():
+ self._config[self._active_num]['has_focus'] = 'both'
+ else:
+ self._config[self._active_num]['has_focus'] = 'yes'
+ else:
+ self._ui.not_has_focus_cb.set_active(True)
+ self._config[self._active_num]['has_focus'] = 'no'
+
+ def _on_not_has_focus_cb_toggled(self, widget):
+ if self._active_num < 0:
+ return
+ if widget.get_active():
+ if self._ui.has_focus_cb.get_active():
+ self._config[self._active_num]['has_focus'] = 'both'
+ else:
+ self._config[self._active_num]['has_focus'] = 'no'
+ else:
+ self._ui.has_focus_cb.set_active(True)
+ self._config[self._active_num]['has_focus'] = 'yes'
+
+ def _on_use_it_toggled(self, widget, opposite_widget, option):
+ if widget.get_active():
+ if opposite_widget.get_active():
+ opposite_widget.set_active(False)
+ self._config[self._active_num][option] = 'yes'
+ elif opposite_widget.get_active():
+ self._config[self._active_num][option] = 'no'
+ else:
+ self._config[self._active_num][option] = ''
+
+ def _on_disable_it_toggled(self, widget, opposite_widget, option):
+ if widget.get_active():
+ if opposite_widget.get_active():
+ opposite_widget.set_active(False)
+ self._config[self._active_num][option] = 'no'
+ elif opposite_widget.get_active():
+ self._config[self._active_num][option] = 'yes'
+ else:
+ self._config[self._active_num][option] = ''
+
+ def _on_use_sound_cb_toggled(self, widget):
+ self._on_use_it_toggled(widget, self._ui.disable_sound_cb, 'sound')
+ if widget.get_active():
+ self._ui.sound_file_box.set_sensitive(True)
+ else:
+ self._ui.sound_file_box.set_sensitive(False)
+
+ def _on_sound_file_set(self, widget):
+ self._config[self._active_num]['sound_file'] = widget.get_filename()
+
+ def _on_play_button_clicked(self, _widget):
+ play_sound_file(self._ui.filechooser.get_filename())
+
+ def _on_disable_sound_cb_toggled(self, widget):
+ self._on_disable_it_toggled(widget, self._ui.use_sound_cb, 'sound')
+
+ def _on_use_popup_cb_toggled(self, widget):
+ self._on_use_it_toggled(widget, self._ui.disable_popup_cb, 'popup')
+
+ def _on_disable_popup_cb_toggled(self, widget):
+ self._on_disable_it_toggled(widget, self._ui.use_popup_cb, 'popup')
+
+ def _on_use_auto_open_cb_toggled(self, widget):
+ self._on_use_it_toggled(widget, self._ui.disable_auto_open_cb,
+ 'auto_open')
+
+ def _on_disable_auto_open_cb_toggled(self, widget):
+ self._on_disable_it_toggled(widget, self._ui.use_auto_open_cb,
+ 'auto_open')
+
+ def _on_run_command_cb_toggled(self, widget):
+ self._config[self._active_num]['run_command'] = widget.get_active()
+ if widget.get_active():
+ self._ui.command_entry.set_sensitive(True)
+ else:
+ self._ui.command_entry.set_sensitive(False)
+
+ def _on_command_entry_changed(self, widget):
+ self._config[self._active_num]['command'] = widget.get_text()
+
+ def _on_use_systray_cb_toggled(self, widget):
+ self._on_use_it_toggled(widget, self._ui.disable_systray_cb, 'systray')
+
+ def _on_disable_systray_cb_toggled(self, widget):
+ self._on_disable_it_toggled(widget, self._ui.use_systray_cb, 'systray')
+
+ def _on_use_roster_cb_toggled(self, widget):
+ self._on_use_it_toggled(widget, self._ui.disable_roster_cb, 'roster')
+
+ def _on_disable_roster_cb_toggled(self, widget):
+ self._on_disable_it_toggled(widget, self._ui.use_roster_cb, 'roster')
+
+ def _on_one_shot_cb_toggled(self, widget):
+ self._config[self._active_num]['one_shot'] = widget.get_active()
+ self._ui.command_entry.set_sensitive(widget.get_active())
diff --git a/triggers/gtk/config.ui b/triggers/gtk/config.ui
new file mode 100644
index 0000000..bf6f416
--- /dev/null
+++ b/triggers/gtk/config.ui
@@ -0,0 +1,1108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.2 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <object class="GtkListStore" id="liststore1">
+ <columns>
+ <!-- column-name item -->
+ <column type="gchararray"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0" translatable="yes">Contact</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Group</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Groupchat participant</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Everybody</col>
+ </row>
+ </data>
+ </object>
+ <object class="GtkListStore" id="liststore2">
+ <columns>
+ <!-- column-name item -->
+ <column type="gchararray"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0" translatable="yes">Receive a Message</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Contact Connects</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Contact Disconnects</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Contact Changes Status</col>
+ </row>
+ </data>
+ </object>
+ <object class="GtkBox" id="box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">18</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="propagate_natural_width">True</property>
+ <property name="propagate_natural_height">True</property>
+ <child>
+ <object class="GtkViewport">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkBox" id="rules_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="height_request">100</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="conditions_treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="enable_grid_lines">horizontal</property>
+ <signal name="cursor-changed" handler="_on_conditions_treeview_cursor_changed" swapped="no"/>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection"/>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolbar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="show_arrow">False</property>
+ <property name="icon_size">1</property>
+ <child>
+ <object class="GtkToolButton" id="up_button">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Up</property>
+ <property name="label" translatable="yes">Up</property>
+ <property name="use_underline">True</property>
+ <property name="stock_id">gtk-go-up</property>
+ <signal name="clicked" handler="_on_up_button_clicked" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolButton" id="down_button">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Down</property>
+ <property name="label" translatable="yes">Down</property>
+ <property name="use_underline">True</property>
+ <property name="stock_id">gtk-go-down</property>
+ <signal name="clicked" handler="_on_down_button_clicked" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolButton" id="new_button">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">New rule</property>
+ <property name="label" translatable="yes">New rule</property>
+ <property name="use_underline">True</property>
+ <property name="stock_id">gtk-new</property>
+ <signal name="clicked" handler="_on_new_button_clicked" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolButton" id="delete_button">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Delete rule</property>
+ <property name="label" translatable="yes">Delete rule</property>
+ <property name="use_underline">True</property>
+ <property name="stock_id">gtk-delete</property>
+ <signal name="clicked" handler="_on_delete_button_clicked" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
+ <style>
+ <class name="inline-toolbar"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="config_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">5</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_top">6</property>
+ <property name="label" translatable="yes">Conditions</property>
+ <property name="use_markup">True</property>
+ <style>
+ <class name="large-header"/>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Event</property>
+ <property name="use_markup">True</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="event_combobox">
+ <property name="width_request">200</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="model">liststore2</property>
+ <signal name="changed" handler="_on_event_combobox_changed" swapped="no"/>
+ <child>
+ <object class="GtkCellRendererText"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Category</property>
+ <property name="use_markup">True</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="recipient_type_combobox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="model">liststore1</property>
+ <signal name="changed" handler="_on_recipient_type_combobox_changed" swapped="no"/>
+ <child>
+ <object class="GtkCellRendererText"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="recipient_list_entry">
+ <property name="width_request">300</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="tooltip_text" translatable="yes">comma separated list</property>
+ <signal name="changed" handler="_on_recipient_list_entry_changed" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">List</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="margin_top">6</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">start</property>
+ <property name="label" translatable="yes">My status</property>
+ <property name="use_markup">True</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="all_status_rb">
+ <property name="label" translatable="yes">All statuses</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="valign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">special_status_rb</property>
+ <signal name="toggled" handler="_on_status_radiobutton_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="special_status_rb">
+ <property name="label" translatable="yes">Certain status</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="valign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">all_status_rb</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkExpander" id="status_expander">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="valign">start</property>
+ <property name="margin_top">3</property>
+ <property name="expanded">True</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkCheckButton" id="online_cb">
+ <property name="label" translatable="yes">Online</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="_on_status_cb_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="away_cb">
+ <property name="label" translatable="yes">Away</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="_on_status_cb_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="xa_cb">
+ <property name="label" translatable="yes">Not Available</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="_on_status_cb_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="dnd_cb">
+ <property name="label" translatable="yes">Busy</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="_on_status_cb_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Status</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Chat Window</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Focus</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="tab_opened_cb">
+ <property name="label" translatable="yes">Opened</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="_on_tab_opened_cb_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="has_focus_cb">
+ <property name="label" translatable="yes">Has focus</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="_on_has_focus_cb_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="not_tab_opened_cb">
+ <property name="label" translatable="yes">Not opened</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="_on_not_tab_opened_cb_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="not_has_focus_cb">
+ <property name="label" translatable="yes">Does not have focus</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="_on_not_has_focus_cb_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_top">6</property>
+ <property name="label" translatable="yes">Actions</property>
+ <property name="use_markup">True</property>
+ <style>
+ <class name="large-header"/>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Chat Window</property>
+ <style>
+ <class name="bold"/>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="use_auto_open_cb">
+ <property name="label" translatable="yes">_Open chat window with contact</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="_on_use_auto_open_cb_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="disable_auto_open_cb">
+ <property name="label" translatable="yes">_Disable automatically opening</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="_on_disable_auto_open_cb_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Notifications</property>
+ <style>
+ <class name="bold"/>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="use_popup_cb">
+ <property name="label" translatable="yes">Not_ificate me with a popup</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="_on_use_popup_cb_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="disable_popup_cb">
+ <property name="label" translatable="yes">_Disable existing notification</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="_on_disable_popup_cb_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Sounds</property>
+ <property name="use_markup">True</property>
+ <style>
+ <class name="bold"/>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkCheckButton" id="use_sound_cb">
+ <property name="label" translatable="yes">Play sound</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="_on_use_sound_cb_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="sound_file_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkFileChooserButton" id="filechooser">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="preview_widget_active">False</property>
+ <property name="use_preview_label">False</property>
+ <property name="title" translatable="yes">Select Sound</property>
+ <property name="width_chars">15</property>
+ <signal name="file-set" handler="_on_sound_file_set" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="play_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <signal name="clicked" handler="_on_play_button_clicked" swapped="no"/>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-media-play</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="disable_sound_cb">
+ <property name="label" translatable="yes">_Disable existing sound for this event</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="_on_disable_sound_cb_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkExpander">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="margin_top">6</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkCheckButton" id="one_shot_cb">
+ <property name="label" translatable="yes">Delete this rule once applied</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="margin_top">6</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="_on_one_shot_cb_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkCheckButton" id="run_command_cb">
+ <property name="label" translatable="yes">Launch command</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="_on_run_command_cb_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="command_entry">
+ <property name="width_request">200</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="placeholder_text" translatable="yes">Command...</property>
+ <signal name="changed" handler="_on_command_entry_changed" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Notification</property>
+ <style>
+ <class name="bold"/>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Contact List</property>
+ <style>
+ <class name="bold"/>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="use_roster_cb">
+ <property name="label" translatable="yes">_Show event</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="_on_use_roster_cb_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="disable_roster_cb">
+ <property name="label" translatable="yes">_Disable showing event</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="_on_disable_roster_cb_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="use_systray_cb">
+ <property name="label" translatable="yes">_Show event</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="_on_use_systray_cb_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="disable_systray_cb">
+ <property name="label" translatable="yes">_Disable showing event</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="_on_disable_systray_cb_toggled" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">7</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Advanced Actions</property>
+ <style>
+ <class name="bold"/>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+</interface>
diff --git a/triggers/triggers.py b/triggers/triggers.py
index 03771a5..844f422 100644
--- a/triggers/triggers.py
+++ b/triggers/triggers.py
@@ -1,59 +1,45 @@
-# -*- coding: utf-8 -*-
+# Copyright (C) 2011-2017 Yann Leboulanger <asterix AT lagaule.org>
+#
+# This file is part of Gajim.
+#
+# Gajim 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; version 3 only.
+#
+# Gajim 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 Gajim. If not, see <http://www.gnu.org/licenses/>.
#
-## plugins/triggers/triggers.py
-##
-## Copyright (C) 2011-2017 Yann Leboulanger <asterix AT lagaule.org>
-##
-## This file is part of Gajim.
-##
-## Gajim 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; version 3 only.
-##
-## Gajim 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 Gajim. If not, see <http://www.gnu.org/licenses/>.
-##
-
-
-import os
-
-from gi.repository import Gtk
+
+from functools import partial
from gajim.common import app
from gajim.common import ged
-from gajim.common import helpers
+
from gajim.plugins import GajimPlugin
-from gajim.plugins.helpers import log_calls
-from gajim.plugins.helpers import get_builder
-from gajim.plugins.gui import GajimPluginConfigDialog
from gajim.plugins.plugins_i18n import _
-from gajim.gtk.filechoosers import NativeFileChooserDialog, Filter
-
-class SoundChooserDialog(NativeFileChooserDialog):
-
- _title = _('Choose Sound')
- _filters = [Filter(_('All files'), '*', False),
- Filter(_('WAV files'), '*.wav', True)]
+from triggers.gtk.config import ConfigDialog
class Triggers(GajimPlugin):
- @log_calls('TriggersPlugin')
def init(self):
- self.description = _('Configure Gajim\'s behaviour with conditions for each contact')
- self.config_dialog = TriggersPluginConfigDialog(self)
+ self.description = _('Configure Gajim’s behaviour with triggers '
+ 'for each contact')
+ self.config_dialog = partial(ConfigDialog, self)
self.config_default_values = {}
- self.events_handlers = {'notification': (ged.PREGUI, self._nec_notif),
+ self.events_handlers = {
+ 'notification': (ged.PREGUI, self._on_notification),
'decrypted-message-received': (ged.PREGUI2,
- self._nec_decrypted_message_received),
- 'gc-message-received': (ged.PREGUI2, self._nec_gc_message_received),
- 'presence-received': (ged.PREGUI, self._nec_presence_received)}
+ self._on_message_received),
+ 'gc-message-received': (ged.PREGUI2, self._on_gc_message_received),
+ 'presence-received': (ged.PREGUI, self._on_presence_received),
+ }
def _check_rule_recipients(self, obj, rule):
rule_recipients = [t.strip() for t in rule['recipients'].split(',')]
@@ -61,11 +47,11 @@ class Triggers(GajimPlugin):
if obj.jid in rule_recipients:
return True
return False
- if rule['recipient_type'] == 'contact' and obj.jid not in \
- rule_recipients:
+ if (rule['recipient_type'] == 'contact' and obj.jid not in
+ rule_recipients):
return False
- contact = app.contacts.get_first_contact_from_jid(obj.conn.name,
- obj.jid)
+ contact = app.contacts.get_first_contact_from_jid(
+ obj.conn.name, obj.jid)
if not contact: # PM?
return False
contact_groups = contact.groups
@@ -118,7 +104,7 @@ class Triggers(GajimPlugin):
return True
- def check_rule_all(self, event, obj, rule):
+ def _check_rule_all(self, event, obj, rule):
# Check notification type
if rule['event'] != event:
return False
@@ -142,7 +128,7 @@ class Triggers(GajimPlugin):
# All is ok
return True
- def check_rule_apply_notif(self, obj, rule):
+ def _check_rule_apply_notification(self, obj, rule):
# Check notification type
notif_type = ''
if obj.notif_type in ('msg', 'gc-msg'):
@@ -155,21 +141,21 @@ class Triggers(GajimPlugin):
else:
notif_type = 'contact_status_change'
- return self.check_rule_all(notif_type, obj, rule)
+ return self._check_rule_all(notif_type, obj, rule)
- def check_rule_apply_decrypted_msg(self, obj, rule):
- return self.check_rule_all('message_received', obj, rule)
+ def _check_rule_apply_msg_received(self, obj, rule):
+ return self._check_rule_all('message_received', obj, rule)
- def check_rule_apply_connected(self, obj, rule):
- return self.check_rule_all('contact_connected', obj, rule)
+ def _check_rule_apply_connected(self, obj, rule):
+ return self._check_rule_all('contact_connected', obj, rule)
- def check_rule_apply_disconnected(self, obj, rule):
- return self.check_rule_all('contact_disconnected', obj, rule)
+ def _check_rule_apply_disconnected(self, obj, rule):
+ return self._check_rule_all('contact_disconnected', obj, rule)
- def check_rule_apply_status_changed(self, obj, rule):
- return self.check_rule_all('contact_status_change', obj, rule)
+ def _check_rule_apply_status_changed(self, obj, rule):
+ return self._check_rule_all('contact_status_change', obj, rule)
- def apply_rule_notif(self, obj, rule):
+ def _apply_rule_notification(self, obj, rule):
if rule['sound'] == 'no':
obj.do_sound = False
elif rule['sound'] == 'yes':
@@ -198,23 +184,19 @@ class Triggers(GajimPlugin):
elif rule['roster'] == 'yes':
obj.show_in_roster = True
-# if rule['urgency_hint'] == 'no':
-# ?? not in obj actions
-# elif rule['urgency_hint'] == 'yes':
-
- def apply_rule_decrypted_message(self, obj, rule):
+ def _apply_rule_message_received(self, obj, rule):
if rule['auto_open'] == 'no':
obj.popup = False
elif rule['auto_open'] == 'yes':
obj.popup = True
- def apply_rule_presence(self, obj, rule):
+ def _apply_rule_presence_received(self, obj, rule):
if rule['auto_open'] == 'no':
obj.popup = False
elif rule['auto_open'] == 'yes':
obj.popup = True
- def _nec_all(self, obj, check_func, apply_func):
+ def _check_all(self, obj, check_func, apply_func):
# check rules in order
rules_num = [int(i) for i in self.config.keys()]
rules_num.sort()
@@ -231,7 +213,7 @@ class Triggers(GajimPlugin):
decal = 0
num = 0
while str(num) in self.config:
- if (num + decal) in to_remove:
+ if num + decal in to_remove:
num2 = num
while str(num2 + 1) in self.config:
self.config[str(num2)] = self.config[str(num2 + 1)].copy()
@@ -241,544 +223,23 @@ class Triggers(GajimPlugin):
else:
num += 1
- def _nec_notif(self, obj):
- self._nec_all(obj, self.check_rule_apply_notif, self.apply_rule_notif)
+ def _on_notification(self, obj):
+ self._check_all(obj, self._check_rule_apply_notification,
+ self._apply_rule_notification)
- def _nec_decrypted_message_received(self, obj):
- self._nec_all(obj, self.check_rule_apply_decrypted_msg,
- self.apply_rule_decrypted_message)
+ def _on_message_received(self, obj):
+ self._check_all(obj, self._check_rule_apply_msg_received,
+ self._apply_rule_message_received)
- def _nec_gc_message_received(self, obj):
- self._nec_all(obj, self.check_rule_apply_decrypted_msg,
- self.apply_rule_decrypted_message)
+ def _on_gc_message_received(self, obj):
+ self._check_all(obj, self._check_rule_apply_msg_received,
+ self._apply_rule_message_received)
- def _nec_presence_received(self, obj):
+ def _on_presence_received(self, obj):
if obj.old_show < 2 and obj.new_show > 1:
- check_func = self.check_rule_apply_connected
+ check_func = self._check_rule_apply_connected
elif obj.old_show > 1 and obj.new_show < 2:
- check_func = self.check_rule_apply_disconnected
- else:
- check_func = self.check_rule_apply_status_changed
- self._nec_all(obj, check_func, self.apply_rule_presence)
-
-
-class TriggersPluginConfigDialog(GajimPluginConfigDialog):
- # {event: widgets_to_disable, }
- events_list = {
- 'message_received': [],
- 'contact_connected': ['use_systray_cb', 'disable_systray_cb',
- 'use_roster_cb', 'disable_roster_cb'],
- 'contact_disconnected': ['use_systray_cb', 'disable_systray_cb',
- 'use_roster_cb', 'disable_roster_cb'],
- 'contact_status_change': ['use_systray_cb', 'disable_systray_cb',
- 'use_roster_cb', 'disable_roster_cb']
- #, 'gc_msg_highlight': [], 'gc_msg': []}
- }
- recipient_types_list = ['contact', 'group', 'groupchat', 'all']
- config_options = ['event', 'recipient_type', 'recipients', 'status',
- 'tab_opened', 'has_focus', 'sound', 'sound_file', 'popup', 'auto_open',
- 'run_command', 'command', 'systray', 'roster', 'urgency_hint',
- 'one_shot']
-
- def init(self):
- path = self.plugin.local_file_path('config_dialog.ui')
- self._ui = get_builder(path, widgets=['plugin_box', 'liststore1', 'liststore2'])
-
- box = self.get_content_area()
- box.pack_start(self._ui.plugin_box, True, True, 0)
-
- self._ui.connect_signals(self)
- self.connect('hide', self.on_hide)
-
- def on_run(self):
- # Fill window
- for w in ('conditions_treeview', 'config_box', 'event_combobox',
- 'recipient_type_combobox', 'recipient_list_entry', 'delete_button',
- 'online_cb', 'away_cb', 'xa_cb', 'dnd_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',
- '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._ui.__dict__[w] = self._ui.get_object(w)
-
- self.config = {}
- for n in self.plugin.config:
- self.config[int(n)] = self.plugin.config[n]
-
- if not self._ui.conditions_treeview.get_column(0):
- # Window never opened
- model = Gtk.ListStore(int, str)
- model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
- self._ui.conditions_treeview.set_model(model)
-
- # '#' Means number
- col = Gtk.TreeViewColumn(_('#'))
- self._ui.conditions_treeview.append_column(col)
- renderer = Gtk.CellRendererText()
- col.pack_start(renderer, expand=False)
- col.add_attribute(renderer, 'text', 0)
-
- col = Gtk.TreeViewColumn(_('Condition'))
- self._ui.conditions_treeview.append_column(col)
- renderer = Gtk.CellRendererText()
- col.pack_start(renderer, expand=True)
- col.add_attribute(renderer, 'text', 1)
- else:
- model = self._ui.conditions_treeview.get_model()
-
- model.clear()
-
- # Fill conditions_treeview
- num = 0
- while num in self.config:
- iter_ = model.append((num, ''))
- path = model.get_path(iter_)
- self._ui.conditions_treeview.set_cursor(path)
- self.active_num = num
- self.initiate_rule_state()
- self.set_treeview_string()
- num += 1
-
- # No rule selected at init time
- self._ui.conditions_treeview.get_selection().unselect_all()
- self.active_num = -1
- self._ui.config_box.set_sensitive(False)
- self._ui.delete_button.set_sensitive(False)
- self._ui.down_button.set_sensitive(False)
- self._ui.up_button.set_sensitive(False)
-
- def initiate_rule_state(self):
- """
- Set values for all widgets
- """
- if self.active_num < 0:
- return
- # event
- value = self.config[self.active_num]['event']
- if value:
- self._ui.event_combobox.set_active(list(self.events_list.keys()).index(
- value))
- else:
- self._ui.event_combobox.set_active(-1)
- # recipient_type
- value = self.config[self.active_num]['recipient_type']
- if value:
- self._ui.recipient_type_combobox.set_active(
- self.recipient_types_list.index(value))
- else:
- self._ui.recipient_type_combobox.set_active(-1)
- # recipient
- value = self.config[self.active_num]['recipients']
- if not value:
- value = ''
- self._ui.recipient_list_entry.set_text(value)
- # status
- value = self.config[self.active_num]['status']
- if value == 'all':
- self._ui.all_status_rb.set_active(True)
- else:
- self._ui.special_status_rb.set_active(True)
- values = value.split()
- for v in ('online', 'away', 'xa', 'dnd'):
- if v in values:
- self._ui.__dict__[v + '_cb'].set_active(True)
- else:
- self._ui.__dict__[v + '_cb'].set_active(False)
-
- self.on_status_radiobutton_toggled(self._ui.all_status_rb)
-
- # tab_opened
- value = self.config[self.active_num]['tab_opened']
- self._ui.tab_opened_cb.set_active(True)
- self._ui.not_tab_opened_cb.set_active(True)
- if value == 'no':
- self._ui.tab_opened_cb.set_active(False)
- elif value == 'yes':
- self._ui.not_tab_opened_cb.set_active(False)
-
- # has_focus
- if 'has_focus' not in self.config[self.active_num]:
- self.config[self.active_num]['has_focus'] = 'both'
- value = self.config[self.active_num]['has_focus']
- self._ui.has_focus_cb.set_active(True)
- self._ui.not_has_focus_cb.set_active(True)
- if value == 'no':
- self._ui.has_focus_cb.set_active(False)
- elif value == 'yes':
- self._ui.not_has_focus_cb.set_active(False)
-
- # sound_file
- value = self.config[self.active_num]['sound_file']
- self._ui.sound_entry.set_text(value)
-
- # sound, popup, auto_open, systray, roster
- for option in ('sound', 'popup', 'auto_open', 'systray', 'roster',
- 'urgency_hint'):
- value = self.config[self.active_num][option]
- if value == 'yes':
- self._ui.__dict__['use_' + option + '_cb'].set_active(True)
- else:
- self._ui.__dict__['use_' + option + '_cb'].set_active(False)
- if value == 'no':
- self._ui.__dict__['disable_' + option + '_cb'].set_active(True)
- else:
- self._ui.__dict__['disable_' + option + '_cb'].set_active(False)
-
- # run_command
- value = self.config[self.active_num]['run_command']
- self._ui.run_command_cb.set_active(value)
-
- # command
- value = self.config[self.active_num]['command']
- self._ui.command_entry.set_text(value)
-
- # one shot
- if 'one_shot' in self.config[self.active_num]:
- value = self.config[self.active_num]['one_shot']
- else:
- value = False
- self._ui.one_shot_cb.set_active(value)
-
- def set_treeview_string(self):
- (model, iter_) = self._ui.conditions_treeview.get_selection().get_selected()
- if not iter_:
- return
- ind = self._ui.event_combobox.get_active()
- event = ''
- if ind > -1:
- event = self._ui.event_combobox.get_model()[ind][0]
- ind = self._ui.recipient_type_combobox.get_active()
- recipient_type = ''
- if ind > -1:
- recipient_type = self._ui.recipient_type_combobox.get_model()[ind][0]
- recipient = ''
- if recipient_type != 'everybody':
- recipient = self._ui.recipient_list_entry.get_text()
- if self._ui.all_status_rb.get_active():
- status = ''
- else:
- status = _('and I am: ')
- for st in ('online', 'away', 'xa', 'dnd'):
- if self._ui.__dict__[st + '_cb'].get_active():
- status += helpers.get_uf_show(st) + ' '
- model[iter_][1] = _('When event: %(event)s for category: '
- '%(recipient_type)s %(recipient)s %(status)s') % {
- 'event': event, 'recipient_type': recipient_type,
- 'recipient': recipient, 'status': status}
-
- def on_conditions_treeview_cursor_changed(self, widget):
- (model, iter_) = widget.get_selection().get_selected()
- if not iter_:
- self.active_num = ''
- return
- self.active_num = model[iter_][0]
- if self.active_num == 0:
- self._ui.up_button.set_sensitive(False)
- else:
- self._ui.up_button.set_sensitive(True)
- _max = self._ui.conditions_treeview.get_model().iter_n_children(None)
- if self.active_num == _max - 1:
- self._ui.down_button.set_sensitive(False)
- else:
- self._ui.down_button.set_sensitive(True)
- self.initiate_rule_state()
- self._ui.config_box.set_sensitive(True)
- self._ui.delete_button.set_sensitive(True)
-
- def on_new_button_clicked(self, widget):
- model = self._ui.conditions_treeview.get_model()
- num = self._ui.conditions_treeview.get_model().iter_n_children(None)
- 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': '',
- 'roster': '', 'one_shot': False, 'urgency_hint': False}
- iter_ = model.append((num, ''))
- path = model.get_path(iter_)
- self._ui.conditions_treeview.set_cursor(path)
- self.active_num = num
- self.set_treeview_string()
- self._ui.config_box.set_sensitive(True)
-
- def on_delete_button_clicked(self, widget):
- (model, iter_) = self._ui.conditions_treeview.get_selection().get_selected()
- if not iter_:
- return
- # up all others
- iter2 = model.iter_next(iter_)
- num = self.active_num
- while iter2:
- num = model[iter2][0]
- model[iter2][0] = num - 1
- self.config[num - 1] = self.config[num].copy()
- iter2 = model.iter_next(iter2)
- model.remove(iter_)
- del self.config[num]
- self.active_num = ''
- self._ui.config_box.set_sensitive(False)
- self._ui.delete_button.set_sensitive(False)
- self._ui.up_button.set_sensitive(False)
- self._ui.down_button.set_sensitive(False)
-
- def on_up_button_clicked(self, widget):
- (model, iter_) = self._ui.conditions_treeview.get_selection().get_selected()
- if not iter_:
- return
- conf = self.config[self.active_num].copy()
- self.config[self.active_num] = self.config[self.active_num - 1]
- self.config[self.active_num - 1] = conf
-
- model[iter_][0] = self.active_num - 1
- # get previous iter
- path = model.get_path(iter_)
- iter_ = model.get_iter((path[0] - 1,))
- model[iter_][0] = self.active_num
- self.on_conditions_treeview_cursor_changed(self._ui.conditions_treeview)
-
- def on_down_button_clicked(self, widget):
- (model, iter_) = self._ui.conditions_treeview.get_selection().get_selected()
- if not iter_:
- return
- conf = self.config[self.active_num].copy()
- self.config[self.active_num] = self.config[self.active_num + 1]
- self.config[self.active_num + 1] = conf
-
- model[iter_][0] = self.active_num + 1
- iter_ = model.iter_next(iter_)
- model[iter_][0] = self.active_num
- self.on_conditions_treeview_cursor_changed(self._ui.conditions_treeview)
-
- def on_event_combobox_changed(self, widget):
- if self.active_num < 0:
- return
- active = self._ui.event_combobox.get_active()
- if active == -1:
- return
- else:
- event = list(self.events_list.keys())[active]
- self.config[self.active_num]['event'] = event
- for w in ('use_systray_cb', 'disable_systray_cb', 'use_roster_cb',
- 'disable_roster_cb'):
- self._ui.__dict__[w].set_sensitive(True)
- for w in self.events_list[event]:
- self._ui.__dict__[w].set_sensitive(False)
- self._ui.__dict__[w].set_state(False)
- self.set_treeview_string()
-
- def on_recipient_type_combobox_changed(self, widget):
- if self.active_num < 0:
- return
- recipient_type = self.recipient_types_list[
- self._ui.recipient_type_combobox.get_active()]
- self.config[self.active_num]['recipient_type'] = recipient_type
- if recipient_type == 'all':
- self._ui.recipient_list_entry.set_sensitive(False)
- else:
- self._ui.recipient_list_entry.set_sensitive(True)
- self.set_treeview_string()
-
- def on_recipient_list_entry_changed(self, widget):
- if self.active_num < 0:
- return
- recipients = widget.get_text()
- #TODO: do some check
- self.config[self.active_num]['recipients'] = recipients
- self.set_treeview_string()
-
- def set_status_config(self):
- if self.active_num < 0:
- return
- status = ''
- for st in ('online', 'away', 'xa', 'dnd'):
- if self._ui.__dict__[st + '_cb'].get_active():
- status += st + ' '
- if status:
- status = status[:-1]
- self.config[self.active_num]['status'] = status
- self.set_treeview_string()
-
- def on_status_radiobutton_toggled(self, widget):
- if self.active_num < 0:
- return
- if self._ui.all_status_rb.get_active():
- self._ui.status_expander.set_expanded(False)
- self.config[self.active_num]['status'] = 'all'
- # 'All status' clicked
- for st in ('online', 'away', 'xa', 'dnd'):
- self._ui.__dict__[st + '_cb'].set_sensitive(False)
- else:
- self._ui.status_expander.set_expanded(True)
- self.set_status_config()
- # 'special status' clicked
- for st in ('online', 'away', 'xa', 'dnd'):
- self._ui.__dict__[st + '_cb'].set_sensitive(True)
-
- self.set_treeview_string()
-
- def on_status_cb_toggled(self, widget):
- if self.active_num < 0:
- return
- self.set_status_config()
-
- # tab_opened OR (not xor) not_tab_opened must be active
- def on_tab_opened_cb_toggled(self, widget):
- if self.active_num < 0:
- return
- if self._ui.tab_opened_cb.get_active():
- self._ui.has_focus_cb.set_sensitive(True)
- self._ui.not_has_focus_cb.set_sensitive(True)
- if self._ui.not_tab_opened_cb.get_active():
- self.config[self.active_num]['tab_opened'] = 'both'
- else:
- self.config[self.active_num]['tab_opened'] = 'yes'
+ check_func = self._check_rule_apply_disconnected
else:
- self._ui.has_focus_cb.set_sensitive(False)
- self._ui.not_has_focus_cb.set_sensitive(False)
- self._ui.not_tab_opened_cb.set_active(True)
- self.config[self.active_num]['tab_opened'] = 'no'
-
- def on_not_tab_opened_cb_toggled(self, widget):
- if self.active_num < 0:
- return
- if self._ui.not_tab_opened_cb.get_active():
- if self._ui.tab_opened_cb.get_active():
- self.config[self.active_num]['tab_opened'] = 'both'
- else:
- self.config[self.active_num]['tab_opened'] = 'no'
- else:
- self._ui.tab_opened_cb.set_active(True)
- self.config[self.active_num]['tab_opened'] = 'yes'
-
- # has_focus OR (not xor) not_has_focus must be active
- def on_has_focus_cb_toggled(self, widget):
- if self.active_num < 0:
- return
- if self._ui.has_focus_cb.get_active():
- if self._ui.not_has_focus_cb.get_active():
- self.config[self.active_num]['has_focus'] = 'both'
- else:
- self.config[self.active_num]['has_focus'] = 'yes'
- else:
- self._ui.not_has_focus_cb.set_active(True)
- self.config[self.active_num]['has_focus'] = 'no'
-
- def on_not_has_focus_cb_toggled(self, widget):
- if self.active_num < 0:
- return
- if self._ui.not_has_focus_cb.get_active():
- if self._ui.has_focus_cb.get_active():
- self.config[self.active_num]['has_focus'] = 'both'
- else:
- self.config[self.active_num]['has_focus'] = 'no'
- else:
- self._ui.has_focus_cb.set_active(True)
- self.config[self.active_num]['has_focus'] = 'yes'
-
- def on_use_it_toggled(self, widget, oposite_widget, option):
- if widget.get_active():
- if oposite_widget.get_active():
- oposite_widget.set_active(False)
- self.config[self.active_num][option] = 'yes'
- elif oposite_widget.get_active():
- self.config[self.active_num][option] = 'no'
- else:
- self.config[self.active_num][option] = ''
-
- def on_disable_it_toggled(self, widget, oposite_widget, option):
- if widget.get_active():
- if oposite_widget.get_active():
- oposite_widget.set_active(False)
- self.config[self.active_num][option] = 'no'
- elif oposite_widget.get_active():
- self.config[self.active_num][option] = 'yes'
- else:
- self.config[self.active_num][option] = ''
-
- def on_use_sound_cb_toggled(self, widget):
- self.on_use_it_toggled(widget, self._ui.disable_sound_cb, 'sound')
- if widget.get_active():
- self._ui.sound_file_box.set_sensitive(True)
- else:
- self._ui.sound_file_box.set_sensitive(False)
-
- def on_browse_for_sounds_button_clicked(self, widget, data=None):
- self._new_filechooser()
-
- def _new_filechooser(self):
- if self.active_num < 0:
- return
-
- def on_ok(path_to_snd_file):
- self.config[self.active_num]['sound_file'] = path_to_snd_file
- self._ui.sound_entry.set_text(path_to_snd_file)
-
- path_to_snd_file = self._ui.sound_entry.get_text()
- path_to_snd_file = os.path.join(os.getcwd(), path_to_snd_file)
- SoundChooserDialog(on_ok,
- path=path_to_snd_file,
- transient_for=self)
-
- def on_play_button_clicked(self, widget):
- helpers.play_sound_file(self._ui.sound_entry.get_text())
-
- def on_disable_sound_cb_toggled(self, widget):
- self.on_disable_it_toggled(widget, self._ui.use_sound_cb, 'sound')
-
- def on_sound_entry_changed(self, widget):
- self.config[self.active_num]['sound_file'] = widget.get_text()
-
- def on_use_popup_cb_toggled(self, widget):
- self.on_use_it_toggled(widget, self._ui.disable_popup_cb, 'popup')
-
- def on_disable_popup_cb_toggled(self, widget):
- self.on_disable_it_toggled(widget, self._ui.use_popup_cb, 'popup')
-
- def on_use_auto_open_cb_toggled(self, widget):
- self.on_use_it_toggled(widget, self._ui.disable_auto_open_cb, 'auto_open')
-
- def on_disable_auto_open_cb_toggled(self, widget):
- self.on_disable_it_toggled(widget, self._ui.use_auto_open_cb, 'auto_open')
-
- def on_run_command_cb_toggled(self, widget):
- self.config[self.active_num]['run_command'] = widget.get_active()
- if widget.get_active():
- self._ui.command_entry.set_sensitive(True)
- else:
- self._ui.command_entry.set_sensitive(False)
-
- def on_command_entry_changed(self, widget):
- self.config[self.active_num]['command'] = widget.get_text()
-
- def on_use_systray_cb_toggled(self, widget):
- self.on_use_it_toggled(widget, self._ui.disable_systray_cb, 'systray')
-
- def on_disable_systray_cb_toggled(self, widget):
- self.on_disable_it_toggled(widget, self._ui.use_systray_cb, 'systray')
-
- def on_use_roster_cb_toggled(self, widget):
- self.on_use_it_toggled(widget, self._ui.disable_roster_cb, 'roster')
-
- def on_disable_roster_cb_toggled(self, widget):
- self.on_disable_it_toggled(widget, self._ui.use_roster_cb, 'roster')
-
- def on_one_shot_cb_toggled(self, widget):
- self.config[self.active_num]['one_shot'] = widget.get_active()
- self._ui.command_entry.set_sensitive(widget.get_active())
-
- def on_use_urgency_hint_cb_toggled(self, widget):
- self.on_use_it_toggled(widget, self._ui.disable_urgency_hint_cb,
- 'uregency_hint')
-
- def on_disable_urgency_hint_cb_toggled(self, widget):
- self.on_disable_it_toggled(widget, self._ui.use_urgency_hint_cb,
- 'uregency_hint')
-
- def on_hide(self, widget):
- # save config
- for n in list(self.plugin.config.keys()):
- del self.plugin.config[n]
- for n in self.config:
- self.plugin.config[str(n)] = self.config[n]
+ check_func = self._check_rule_apply_status_changed
+ self._check_all(obj, check_func, self._apply_rule_presence_received)