Commit fb3dbf48 authored by Alexander's avatar Alexander

[stickers] Add a reload button

parent 1d8d5fbe
......@@ -64,6 +64,8 @@ class StickersConfigDialog(GajimPluginConfigDialog):
self._ui.sticker_width.set_increments(1, -1)
self._ui.sticker_packs_list.bind_model(self._list_model, self._create_sticker_pack_row)
self._ui.reload_sticker_packs.connect('clicked', self.on_sticker_packs_reload_clicked)
def set_wrapper(setting):
return lambda widget: self._on_setting_changed(widget, setting)
......@@ -72,6 +74,9 @@ class StickersConfigDialog(GajimPluginConfigDialog):
getattr(self._ui, setting).connect('toggled', set_wrapper(setting.upper()))
self._ui.sticker_width.connect('value-changed', set_wrapper('STICKER_WIDTH'))
def on_sticker_packs_reload_clicked(self, button):
self.plugin.reload_sticker_packs()
def on_sticker_pack_added(self, pack):
'''
Called when a new sticker pack has been added.
......
......@@ -6,13 +6,47 @@
<property name="visible">True</property>
<property name="can-focus">True</property>
<child>
<object class="GtkListBox" id="sticker_packs_list">
<!-- n-columns=1 n-rows=2 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">18</property>
<property name="margin-end">18</property>
<property name="margin-top">18</property>
<property name="margin-bottom">18</property>
<child>
<object class="GtkListBox" id="sticker_packs_list">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">18</property>
<property name="margin-end">18</property>
<property name="margin-top">18</property>
<property name="margin-bottom">18</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="reload_sticker_packs">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">end</property>
<property name="margin-end">12</property>
<property name="margin-top">12</property>
<property name="hexpand">True</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="tooltip-text" translatable="yes">Reload sticker packs</property>
<property name="stock">gtk-refresh</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
</object>
</child>
<child type="tab">
......
......@@ -281,6 +281,17 @@ class StickersPlugin(GajimPlugin):
'''
self.config_dialog.on_sticker_pack_added(pack)
def reload_sticker_packs(self):
'''
Searches again for sticker packs and loads them.
'''
log.debug('Reloading sticker packs')
# To prevent duplicate sticker packs in the config dialog, first remove
# them all
for sticker_pack in self.sticker_packs.values():
self.config_dialog.on_sticker_pack_removed(sticker_pack)
self._load_sticker_packs()
def _load_sticker_packs(self):
path = sticker_data_path()
if not os.path.exists(path):
......@@ -340,7 +351,7 @@ class StickersPlugin(GajimPlugin):
summary=info['summary'],
stickers=stickers)
self._on_sticker_pack_added(self.sticker_packs[id_])
log.debug('Sticker pack %s loaded', info["name"])
log.debug('Sticker pack %s loaded', info['name'])
def _process_sticker_mentions(self, pack):
if not pack.id_ in self.sticker_mentions:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment