[client_icons] Use new config dialog
This commit is contained in:
@@ -1,24 +1,22 @@
|
|||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
from nbxmpp import JID
|
|
||||||
|
|
||||||
from clients_icons import clients
|
|
||||||
|
|
||||||
from gajim.roster_window import Column
|
from gajim.roster_window import Column
|
||||||
|
|
||||||
from gajim.plugins import GajimPlugin
|
|
||||||
from gajim.plugins.gui import GajimPluginConfigDialog
|
|
||||||
from gajim.plugins.plugins_i18n import _
|
|
||||||
|
|
||||||
from gajim.common import ged
|
from gajim.common import ged
|
||||||
from gajim.common import app
|
from gajim.common import app
|
||||||
from gajim.common import caps_cache
|
from gajim.common import caps_cache
|
||||||
|
|
||||||
|
|
||||||
from gajim.gtk.util import load_icon
|
from gajim.gtk.util import load_icon
|
||||||
|
|
||||||
|
from gajim.plugins import GajimPlugin
|
||||||
|
from gajim.plugins.plugins_i18n import _
|
||||||
|
|
||||||
|
from clients_icons import clients
|
||||||
|
from clients_icons.config_dialog import ClientsIconsConfigDialog
|
||||||
|
|
||||||
|
from nbxmpp import JID
|
||||||
|
|
||||||
log = logging.getLogger('gajim.p.client_icons')
|
log = logging.getLogger('gajim.p.client_icons')
|
||||||
|
|
||||||
@@ -27,7 +25,8 @@ class ClientsIconsPlugin(GajimPlugin):
|
|||||||
def init(self):
|
def init(self):
|
||||||
self.description = _('Shows client icons in roster'
|
self.description = _('Shows client icons in roster'
|
||||||
' and in groupchats.')
|
' and in groupchats.')
|
||||||
self.pos_list = [_('after statusicon'), _('before avatar')]
|
self.config_dialog = partial(ClientsIconsConfigDialog, self)
|
||||||
|
|
||||||
self.events_handlers = {
|
self.events_handlers = {
|
||||||
'caps-update': (ged.POSTGUI, self._on_caps_update),
|
'caps-update': (ged.POSTGUI, self._on_caps_update),
|
||||||
}
|
}
|
||||||
@@ -43,7 +42,7 @@ class ClientsIconsPlugin(GajimPlugin):
|
|||||||
'show_in_groupchats': (True, ''),
|
'show_in_groupchats': (True, ''),
|
||||||
'show_in_tooltip': (True, ''),
|
'show_in_tooltip': (True, ''),
|
||||||
'show_unknown_icon': (True, ''),
|
'show_unknown_icon': (True, ''),
|
||||||
'pos_in_list': (0, ''),
|
'pos_in_list': ('0', ''),
|
||||||
'show_facebook': (True, ''),
|
'show_facebook': (True, ''),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +50,6 @@ class ClientsIconsPlugin(GajimPlugin):
|
|||||||
if _icon_theme is not None:
|
if _icon_theme is not None:
|
||||||
_icon_theme.append_search_path(str(Path(__file__).parent))
|
_icon_theme.append_search_path(str(Path(__file__).parent))
|
||||||
|
|
||||||
self.config_dialog = ClientsIconsPluginConfigDialog(self)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_client_identity_name(contact):
|
def get_client_identity_name(contact):
|
||||||
@@ -217,7 +215,7 @@ class ClientsIconsPlugin(GajimPlugin):
|
|||||||
chat_control.list_treeview.get_column(0))
|
chat_control.list_treeview.get_column(0))
|
||||||
# add new renderer in renderers list
|
# add new renderer in renderers list
|
||||||
position_list = ['name', 'avatar']
|
position_list = ['name', 'avatar']
|
||||||
position = position_list[self.config['pos_in_list']]
|
position = position_list[int(self.config['pos_in_list'])]
|
||||||
for renderer in chat_control.renderers_list:
|
for renderer in chat_control.renderers_list:
|
||||||
if renderer[0] == position:
|
if renderer[0] == position:
|
||||||
break
|
break
|
||||||
@@ -282,7 +280,7 @@ class ClientsIconsPlugin(GajimPlugin):
|
|||||||
roster.tree.remove_column(roster.tree.get_column(0))
|
roster.tree.remove_column(roster.tree.get_column(0))
|
||||||
# add new renderer in renderers list
|
# add new renderer in renderers list
|
||||||
position_list = ['name', 'avatar']
|
position_list = ['name', 'avatar']
|
||||||
position = position_list[self.config['pos_in_list']]
|
position = position_list[int(self.config['pos_in_list'])]
|
||||||
for renderer in roster.renderers_list:
|
for renderer in roster.renderers_list:
|
||||||
if renderer[0] == position:
|
if renderer[0] == position:
|
||||||
break
|
break
|
||||||
@@ -430,72 +428,3 @@ class ClientsIconsPlugin(GajimPlugin):
|
|||||||
else:
|
else:
|
||||||
renderer.set_property('cell-background', None)
|
renderer.set_property('cell-background', None)
|
||||||
renderer.set_property('width', 16)
|
renderer.set_property('width', 16)
|
||||||
|
|
||||||
|
|
||||||
class ClientsIconsPluginConfigDialog(GajimPluginConfigDialog):
|
|
||||||
def init(self):
|
|
||||||
self.Gtk_BUILDER_FILE_PATH = self.plugin.local_file_path(
|
|
||||||
'config_dialog.ui')
|
|
||||||
self.xml = Gtk.Builder()
|
|
||||||
self.xml.set_translation_domain('gajim_plugins')
|
|
||||||
self.xml.add_objects_from_file(self.Gtk_BUILDER_FILE_PATH, ['vbox1'])
|
|
||||||
vbox = self.xml.get_object('vbox1')
|
|
||||||
self.get_child().pack_start(vbox, True, True, 0)
|
|
||||||
self.combo = self.xml.get_object('combobox1')
|
|
||||||
self.liststore = Gtk.ListStore(str)
|
|
||||||
self.combo.set_model(self.liststore)
|
|
||||||
cellrenderer = Gtk.CellRendererText()
|
|
||||||
self.combo.pack_start(cellrenderer, True)
|
|
||||||
self.combo.add_attribute(cellrenderer, 'text', 0)
|
|
||||||
|
|
||||||
for item in self.plugin.pos_list:
|
|
||||||
self.liststore.append((item,))
|
|
||||||
self.combo.set_active(self.plugin.config['pos_in_list'])
|
|
||||||
|
|
||||||
self.xml.get_object('show_in_roster').set_active(
|
|
||||||
self.plugin.config['show_in_roster'])
|
|
||||||
self.xml.get_object('show_in_groupchats').set_active(
|
|
||||||
self.plugin.config['show_in_groupchats'])
|
|
||||||
self.xml.get_object('show_unknown_icon').set_active(
|
|
||||||
self.plugin.config['show_unknown_icon'])
|
|
||||||
self.xml.get_object('show_facebook').set_active(
|
|
||||||
self.plugin.config['show_facebook'])
|
|
||||||
self.xml.get_object('show_in_tooltip').set_active(
|
|
||||||
self.plugin.config['show_in_tooltip'])
|
|
||||||
|
|
||||||
self.xml.connect_signals(self)
|
|
||||||
|
|
||||||
def redraw_all(self):
|
|
||||||
self.plugin.deactivate()
|
|
||||||
self.plugin.activate()
|
|
||||||
for gc_control in app.interface.msg_win_mgr.get_controls('gc'):
|
|
||||||
self.plugin.disconnect_from_groupchat_control(gc_control)
|
|
||||||
for gc_control in app.interface.msg_win_mgr.get_controls('gc'):
|
|
||||||
self.plugin.connect_with_groupchat_control(gc_control)
|
|
||||||
|
|
||||||
def on_show_in_roster_toggled(self, widget):
|
|
||||||
self.plugin.config['show_in_roster'] = widget.get_active()
|
|
||||||
self.plugin.deactivate()
|
|
||||||
self.plugin.activate()
|
|
||||||
|
|
||||||
def on_show_in_tooltip_toggled(self, widget):
|
|
||||||
self.plugin.config['show_in_tooltip'] = widget.get_active()
|
|
||||||
|
|
||||||
def on_show_in_groupchats_toggled(self, widget):
|
|
||||||
self.plugin.config['show_in_groupchats'] = widget.get_active()
|
|
||||||
for gc_control in app.interface.msg_win_mgr.get_controls('gc'):
|
|
||||||
self.plugin.disconnect_from_groupchat_control(gc_control)
|
|
||||||
for gc_control in app.interface.msg_win_mgr.get_controls('gc'):
|
|
||||||
self.plugin.connect_with_groupchat_control(gc_control)
|
|
||||||
|
|
||||||
def on_show_unknown_icon_toggled(self, widget):
|
|
||||||
self.plugin.config['show_unknown_icon'] = widget.get_active()
|
|
||||||
self.redraw_all()
|
|
||||||
|
|
||||||
def on_show_facebook_toggled(self, widget):
|
|
||||||
self.plugin.config['show_facebook'] = widget.get_active()
|
|
||||||
self.redraw_all()
|
|
||||||
|
|
||||||
def on_combobox1_changed(self, widget):
|
|
||||||
self.plugin.config['pos_in_list'] = widget.get_active()
|
|
||||||
self.redraw_all()
|
|
||||||
|
|||||||
77
clients_icons/config_dialog.py
Normal file
77
clients_icons/config_dialog.py
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
# 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, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# 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 gi.repository import Gtk
|
||||||
|
|
||||||
|
from gajim.common import app
|
||||||
|
|
||||||
|
from gajim.gtk.settings import SettingsDialog
|
||||||
|
from gajim.gtk.const import Setting
|
||||||
|
from gajim.gtk.const import SettingKind
|
||||||
|
from gajim.gtk.const import SettingType
|
||||||
|
|
||||||
|
from gajim.plugins.plugins_i18n import _
|
||||||
|
|
||||||
|
|
||||||
|
class ClientsIconsConfigDialog(SettingsDialog):
|
||||||
|
def __init__(self, plugin, parent):
|
||||||
|
|
||||||
|
icon_position = [
|
||||||
|
('0', _('Before Avatar')),
|
||||||
|
('1', _('After Status Icon'))]
|
||||||
|
|
||||||
|
self.plugin = plugin
|
||||||
|
settings = [
|
||||||
|
Setting(SettingKind.SWITCH, _('Show Icons in Contact List'),
|
||||||
|
SettingType.VALUE, self.plugin.config['show_in_roster'],
|
||||||
|
callback=self._on_setting, data='show_in_roster'),
|
||||||
|
|
||||||
|
Setting(SettingKind.SWITCH, _('Show Icons in Group Chats'),
|
||||||
|
SettingType.VALUE, self.plugin.config['show_in_groupchats'],
|
||||||
|
callback=self._on_setting, data='show_in_groupchats'),
|
||||||
|
|
||||||
|
Setting(SettingKind.SWITCH, _('Show Icons in Tooltip'),
|
||||||
|
SettingType.VALUE, self.plugin.config['show_in_tooltip'],
|
||||||
|
callback=self._on_setting, data='show_in_tooltip'),
|
||||||
|
|
||||||
|
Setting(SettingKind.SWITCH, _('Show Icon for Unknown Clients'),
|
||||||
|
SettingType.VALUE, self.plugin.config['show_unknown_icon'],
|
||||||
|
callback=self._on_setting, data='show_unknown_icon'),
|
||||||
|
|
||||||
|
Setting(SettingKind.SWITCH, _('Show Icon for Transports'),
|
||||||
|
SettingType.VALUE, self.plugin.config['show_facebook'],
|
||||||
|
desc=_('Icons for facebook.com and vk.com'),
|
||||||
|
callback=self._on_setting, data='show_facebook'),
|
||||||
|
|
||||||
|
Setting(SettingKind.COMBO, _('Icon Position'),
|
||||||
|
SettingType.VALUE, self.plugin.config['pos_in_list'],
|
||||||
|
callback=self._on_setting, data='pos_in_list',
|
||||||
|
props={'combo_items': icon_position}),
|
||||||
|
]
|
||||||
|
|
||||||
|
SettingsDialog.__init__(self, parent, _('Clients Icons Configuration'),
|
||||||
|
Gtk.DialogFlags.MODAL, settings, None)
|
||||||
|
|
||||||
|
def _on_setting(self, value, data):
|
||||||
|
self.plugin.config[data] = value
|
||||||
|
self._redraw_all()
|
||||||
|
|
||||||
|
def _redraw_all(self):
|
||||||
|
self.plugin.deactivate()
|
||||||
|
self.plugin.activate()
|
||||||
|
for gc_control in app.interface.msg_win_mgr.get_controls('gc'):
|
||||||
|
self.plugin.disconnect_from_groupchat_control(gc_control)
|
||||||
|
for gc_control in app.interface.msg_win_mgr.get_controls('gc'):
|
||||||
|
self.plugin.connect_with_groupchat_control(gc_control)
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<interface>
|
|
||||||
<requires lib="gtk+" version="2.16"/>
|
|
||||||
<!-- interface-naming-policy toplevel-contextual -->
|
|
||||||
<object class="GtkWindow" id="window1">
|
|
||||||
<child>
|
|
||||||
<object class="GtkVBox" id="vbox1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkCheckButton" id="show_in_roster">
|
|
||||||
<property name="label" translatable="yes">Show icons in roster</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="receives_default">False</property>
|
|
||||||
<property name="draw_indicator">True</property>
|
|
||||||
<signal name="toggled" handler="on_show_in_roster_toggled"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkCheckButton" id="show_in_groupchats">
|
|
||||||
<property name="label" translatable="yes">Show icons in groupchats</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="receives_default">False</property>
|
|
||||||
<property name="draw_indicator">True</property>
|
|
||||||
<signal name="toggled" handler="on_show_in_groupchats_toggled"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkCheckButton" id="show_in_tooltip">
|
|
||||||
<property name="label" translatable="yes">Show icons in tooltip</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="receives_default">False</property>
|
|
||||||
<property name="draw_indicator">True</property>
|
|
||||||
<signal name="toggled" handler="on_show_in_tooltip_toggled"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="position">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkCheckButton" id="show_unknown_icon">
|
|
||||||
<property name="label" translatable="yes">Show icon for an unknown client</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="receives_default">False</property>
|
|
||||||
<property name="draw_indicator">True</property>
|
|
||||||
<signal name="toggled" handler="on_show_unknown_icon_toggled"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="position">3</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkCheckButton" id="show_facebook">
|
|
||||||
<property name="label" translatable="yes">Show icon for facebook.com and vk.com</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="receives_default">False</property>
|
|
||||||
<property name="draw_indicator">True</property>
|
|
||||||
<signal name="toggled" handler="on_show_facebook_toggled"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="position">4</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkHBox" id="hbox1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel" id="label1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="xpad">3</property>
|
|
||||||
<property name="label" translatable="yes">Show icon:</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkComboBox" id="combobox1">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<signal name="changed" handler="on_combobox1_changed"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="position">5</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</interface>
|
|
||||||
Reference in New Issue
Block a user