Commit 1866cdfd authored by Philipp Hörist's avatar Philipp Hörist

Remove EmoticonsPackPlugin

parent fabfa3e7
from .emoticons_pack import EmoticonsPackPlugin
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkTextBuffer" id="textbuffer1">
<property name="text">Plug-in decription should be displayed here. This text will be erased during PluginsWindow initialization.</property>
</object>
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<child>
<object class="GtkHPaned" id="hpaned2">
<property name="width_request">600</property>
<property name="height_request">350</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="position">340</property>
<property name="position_set">True</property>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="border_width">6</property>
<property name="hscrollbar_policy">never</property>
<child>
<object class="GtkTreeView" id="available_treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="search_column">1</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1">
<property name="mode">none</property>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="resize">False</property>
<property name="shrink">False</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="set_name">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label">empty</property>
<property name="selectable">True</property>
<property name="ellipsize">end</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox8">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Authors:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="authors_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">6</property>
<property name="label">&lt;empty&gt;</property>
<property name="selectable">True</property>
<property name="ellipsize">end</property>
</object>
<packing>
<property name="expand">True</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="GtkHBox" id="hbox3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Converted by:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="converter_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">6</property>
<property name="label">&lt;empty&gt;</property>
<property name="selectable">True</property>
<property name="ellipsize">end</property>
</object>
<packing>
<property name="expand">True</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">2</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox9">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Homepage:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLinkButton" id="homepage_linkbutton">
<property name="label">button</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="relief">none</property>
<property name="focus_on_click">False</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">True</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">3</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkHBox" id="hbox10">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="label10">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Description:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</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="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox15">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkButton" id="inslall_upgrade_button">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<signal name="clicked" handler="on_inslall_upgrade_clicked" swapped="no"/>
<child>
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-refresh</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Install/Upgrade</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="legend_button">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">True</property>
<property name="margin_left">22</property>
<property name="use_action_appearance">False</property>
<signal name="clicked" handler="on_legend_button_clicked" swapped="no"/>
<child>
<object class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-info</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Legend</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</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">5</property>
</packing>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">False</property>
</packing>
</child>
</object>
</child>
</object>
</interface>
[MacThemes2]
icon: Smile.png
description: <body xmlns='http://www.w3.org/1999/xhtml'>
Mac Themes 2 Smilies <br/>
<img src="preview.image"/>
</body>
authors: David Lanham
homepage: https://trac.gajim.org/wiki/MacThemes2
[Citters Emoticons from Psi]
icon: smile.png
description: <body xmlns='http://www.w3.org/1999/xhtml'>
Citters Emoticons from Psi<br/>
<img src="preview.image"/>
</body>
converter: churchyard (JID: churchyard@njs.netlab.cz)
homepage: https://trac.gajim.org/wiki/cittersemoticons
[Google Talk Emoticons]
icon: equal_smile.gif
description: <body xmlns='http://www.w3.org/1999/xhtml'>
Google Talk Emoticons<br/>
<img src="preview.image"/>
</body>
converter: Chris Cook
homepage: https://trac.gajim.org/wiki/gtalkemoticons
[ICQ6 Emoticons]
icon: Smiley1.gif
description: <body xmlns='http://www.w3.org/1999/xhtml'>
ICQ6 Emoticons<br/>
<img src="preview.image"/>
</body>
homepage: https://trac.gajim.org/wiki/ICQ6-emotions
[Kolobok Animated Emoticons]
icon: ab.gif
description: <body xmlns='http://www.w3.org/1999/xhtml'>
Kolobok Animated Emoticons<br/>
<img src="preview.image"/>
</body>
homepage: https://trac.gajim.org/wiki/kolobok-animated-emoticons
[Pidgin Emoticons]
icon: smile.png
description: <body xmlns='http://www.w3.org/1999/xhtml'>
Pidgin Emoticons<br/>
<img src="preview.image"/>
</body>
homepage: https://trac.gajim.org/wiki/PidginEmoticons
[Psynova qip's theme]
icon: ab.gif
authors: zOrg
description: <body xmlns='http://www.w3.org/1999/xhtml'>
Psynova qip's theme<br/>
<img src="preview.image"/>
</body>
homepage: https://trac.gajim.org/wiki/psynovaemoticons
[Yahoo Emoticons]
icon: equal_smile.gif
description: <body xmlns='http://www.w3.org/1999/xhtml'>
Yahoo Emoticons<br/>
<img src="preview.image"/>
</body>
homepage: https://trac.gajim.org/wiki/YahooEmoticons
[Nekomoticons]
icon: s01.jpg
authors: somik (http://somik.deviantart.com/)
converter: Dotterian (http://dotterian.ru/)
description: <body xmlns='http://www.w3.org/1999/xhtml'>
Nekomoticons<br/>
<img src="preview.image"/>
</body>
homepage: https://trac.gajim.org/wiki/Nekomoticons
[Trollicons]
icon: Happy-EverythingWentBetterThanExpected.png
authors: Sagar Pandya
Chris Li
Jonathan E. Chen
converter: Matthieu L.
description: <body xmlns='http://www.w3.org/1999/xhtml'>
Trollicons (Rage Icons for Gajim)<br/>
<img src="preview.image"/>
</body>
homepage: https://github.com/sagargp/trollicons/blob/master/readme.md#downloads
# -*- coding: utf-8 -*-
##
from gi.repository import Gtk
from gi.repository import GdkPixbuf
from gi.repository import Pango
from gi.repository import GObject
import configparser
import os
import zipfile
import tempfile
from shutil import rmtree
import sys
import imp
import posixpath
from enum import IntEnum
from common import gajim
from plugins import GajimPlugin
from plugins.helpers import log_calls
from htmltextview import HtmlTextView
from dialogs import WarningDialog, HigDialog
class Column(IntEnum):
PIXBUF = 0
NAME = 1
DESCRIPTION = 2
AUTHORS = 3
CONVERTER = 4
HOMEPAGE = 5
UPGRADE = 6
class EmoticonsPackPlugin(GajimPlugin):
@log_calls('EmoticonsPackPlugin')
def init(self):
self.description = _('Install, update and view detailed legend '
'of emoticons')
self.config_dialog = None # EmoticonsPackPluginConfigDialog(self)
self.gui_extension_points = {'plugin_window': (self.on_activate, None)}
self.window = None
self.model = None
self.connected_ids = {}
self.tmp_dir = ''
@log_calls('EmoticonsPackPlugin')
def activate(self):
if 'plugins' in gajim.interface.instances:
self.on_activate(gajim.interface.instances['plugins'])
@log_calls('EmoticonsPackPlugin')
def deactivate(self):
if hasattr(self, 'page_num'):
self.notebook.remove_page(self.notebook.page_num(self.hpaned))
self.notebook.set_current_page(0)
for id_, widget in list(self.connected_ids.items()):
widget.disconnect(id_)
del self.page_num
def on_activate(self, plugin_win):
if hasattr(self, 'page_num'):
# 'Available' tab exists
return
self.notebook = plugin_win.plugins_notebook
id_ = self.notebook.connect(
'switch-page', self.on_notebook_switch_page)
self.connected_ids[id_] = self.notebook
self.window = plugin_win.window
id_ = self.window.connect('destroy', self.on_win_destroy)
self.connected_ids[id_] = self.window
self.Gtk_BUILDER_FILE_PATH = self.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, ['hpaned2'])
self.hpaned = self.xml.get_object('hpaned2')
self.page_num = self.notebook.append_page(self.hpaned, Gtk.Label(_(
'Emoticons')))
widgets_to_extract = (
'set_name', 'available_treeview', 'homepage_linkbutton',
'inslall_upgrade_button', 'authors_label', 'converter_label',)
for widget_name in widgets_to_extract:
setattr(self, widget_name, self.xml.get_object(widget_name))
self.model = Gtk.ListStore(
GdkPixbuf.Pixbuf, GObject.TYPE_STRING,
GObject.TYPE_STRING, GObject.TYPE_STRING,
GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_BOOLEAN)
self.available_treeview.set_model(self.model)
self.available_treeview.set_rules_hint(True)
self.model.set_sort_column_id(1, Gtk.SortType.ASCENDING)
renderer = Gtk.CellRendererText()
col = Gtk.TreeViewColumn(_('Name'))
cell = Gtk.CellRendererPixbuf()
col.pack_start(cell, False)
col.add_attribute(cell, 'pixbuf', Column.PIXBUF)
col.pack_start(renderer, True)
col.add_attribute(renderer, 'text', Column.NAME)
col.set_property('expand', True)
col.set_sizing(Gtk.TreeViewColumnSizing.GROW_ONLY)
self.available_treeview.append_column(col)
renderer = Gtk.CellRendererToggle()
renderer.set_property('activatable', True)
renderer.connect('toggled', self.available_emoticons_toggled_cb)
col = Gtk.TreeViewColumn(
_('Install /\nUpgrade'), renderer, active=Column.UPGRADE)
col.set_property('expand', False)
col.set_resizable(False)
self.available_treeview.append_column(col)
selection = self.available_treeview.get_selection()
selection.connect('changed', self.emoticons_treeview_selection_changed)
selection.set_mode(Gtk.SelectionMode.SINGLE)
self.emoticons_description_textview = HtmlTextView()
sw = self.xml.get_object('scrolledwindow1')
sw.add(self.emoticons_description_textview)
self.xml.connect_signals(self)
self.window.show_all()
def on_legend_button_clicked(self, widget):
treeview_selection = self.available_treeview.get_selection()
model, iter = treeview_selection.get_selected()
name = model.get_value(iter, Column.NAME)
self.emoticons_description_textview.get_buffer().set_text('')
label = self.xml.get_object('label2')
if label.get_text() == _('Legend'):
label.set_text(_('Description'))
sys.path.append(os.path.join(self.tmp_dir, name))
import emoticons
imp.reload(emoticons)
buff = self.emoticons_description_textview.get_buffer()
for icon in emoticons.emoticons:
icon_file = os.path.join(self.tmp_dir, name, icon)
with open(icon_file, 'rb') as _file:
data = _file.read()
pbl = GdkPixbuf.PixbufLoader()
pbl.write(data)
pbl.close()
if icon.endswith('.gif'):
img = Gtk.Image()
img.set_from_animation(pbl.get_animation())
img.show()
anchor = buff.create_child_anchor(buff.get_end_iter())
self.emoticons_description_textview.add_child_at_anchor(
img, anchor)
else:
buff.insert_pixbuf(buff.get_end_iter(), pbl.get_pixbuf())
text = ' , '.join(emoticons.emoticons[icon])
buff.insert(buff.get_end_iter(), text + '\n', -1)