Added GajimPluginConfigDialog class - dialog that plugins should use to present configuration to user.
Now, 'Configure' button is invoked only for plug-ins that have config_dialog.
This commit is contained in:
parent
8581b862e1
commit
aaf5b30129
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
|
||||
<!--Generated with glade3 3.4.5 on Mon Jun 9 15:22:01 2008 -->
|
||||
<!--Generated with glade3 3.4.5 on Thu Jun 19 13:11:54 2008 -->
|
||||
<glade-interface>
|
||||
<widget class="GtkWindow" id="plugins_window">
|
||||
<property name="width_request">650</property>
|
||||
|
@ -242,6 +242,7 @@
|
|||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<signal name="clicked" handler="on_uninstall_plugin_button_clicked"/>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox11">
|
||||
<property name="visible">True</property>
|
||||
|
@ -270,6 +271,7 @@
|
|||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="response_id">0</property>
|
||||
<signal name="clicked" handler="on_configure_plugin_button_clicked"/>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox12">
|
||||
<property name="visible">True</property>
|
||||
|
|
|
@ -44,6 +44,8 @@ class AcronymsExpanderPlugin(GajimPlugin):
|
|||
#super(AcronymsExpanderPlugin, self).__init__()
|
||||
|
||||
def init(self):
|
||||
self.config_dialog = None
|
||||
|
||||
self.gui_extension_points = {
|
||||
'chat_control_base' : (self.connect_with_chat_control_base,
|
||||
self.disconnect_from_chat_control_base)
|
||||
|
|
|
@ -45,6 +45,8 @@ class LengthNotifierPlugin(GajimPlugin):
|
|||
|
||||
@log_calls('LengthNotifierPlugin')
|
||||
def init(self):
|
||||
#self.config_dialog = None
|
||||
|
||||
self.gui_extension_points = {
|
||||
'chat_control' : (self.connect_with_chat_control,
|
||||
self.disconnect_from_chat_control)
|
||||
|
|
|
@ -52,6 +52,8 @@ class RosterButtonsPlugin(GajimPlugin):
|
|||
|
||||
self.roster_vbox = gajim.interface.roster.xml.get_widget('roster_vbox2')
|
||||
self.show_offline_contacts_menuitem = gajim.interface.roster.xml.get_widget('show_offline_contacts_menuitem')
|
||||
|
||||
self.config_dialog = None
|
||||
|
||||
@log_calls('RosterButtonsPlugin')
|
||||
def activate(self):
|
||||
|
|
|
@ -117,7 +117,10 @@ class PluginsWindow(object):
|
|||
desc_textbuffer.set_text(plugin.description)
|
||||
self.plugin_description_textview.set_property('sensitive', True)
|
||||
self.uninstall_plugin_button.set_property('sensitive', True)
|
||||
self.configure_plugin_button.set_property('sensitive', True)
|
||||
if plugin.config_dialog is None:
|
||||
self.configure_plugin_button.set_property('sensitive', False)
|
||||
else:
|
||||
self.configure_plugin_button.set_property('sensitive', True)
|
||||
|
||||
def _clear_installed_plugin_info(self):
|
||||
self.plugin_name_label.set_text('')
|
||||
|
@ -163,4 +166,54 @@ class PluginsWindow(object):
|
|||
|
||||
@log_calls('PluginsWindow')
|
||||
def on_close_button_clicked(self, widget):
|
||||
self.window.destroy()
|
||||
self.window.destroy()
|
||||
|
||||
@log_calls('PluginsWindow')
|
||||
def on_configure_plugin_button_clicked(self, widget):
|
||||
log.debug('widget: %s'%(widget))
|
||||
selection = self.installed_plugins_treeview.get_selection()
|
||||
model, iter = selection.get_selected()
|
||||
if iter:
|
||||
plugin = model.get_value(iter, 0)
|
||||
plugin_name = model.get_value(iter, 1)
|
||||
is_active = model.get_value(iter, 2)
|
||||
|
||||
|
||||
result = plugin.config_dialog.run(self.window)
|
||||
|
||||
else:
|
||||
# No plugin selected. this should never be reached. As configure
|
||||
# plugin button should only my clickable when plugin is selected.
|
||||
# XXX: maybe throw exception here?
|
||||
pass
|
||||
|
||||
@log_calls('PluginsWindow')
|
||||
def on_uninstall_plugin_button_clicked(self, widget):
|
||||
pass
|
||||
|
||||
|
||||
class GajimPluginConfigDialog(gtk.Dialog):
|
||||
|
||||
@log_calls('GajimPluginConfigDialog')
|
||||
def __init__(self, plugin, **kwargs):
|
||||
# TRANSLATORS: The window title for the generic configuration dialog of plugins
|
||||
gtk.Dialog.__init__(self, '%s : %s'%(_('Configuration'), plugin.name), **kwargs)
|
||||
self.plugin = plugin
|
||||
self.add_button('gtk-close', gtk.RESPONSE_CLOSE)
|
||||
|
||||
self.main = self.child
|
||||
self.main.set_spacing(3)
|
||||
|
||||
# TRANSLATORS: Short text stating which plugin a configuration dialog is for
|
||||
label = gtk.Label(_('<b>%s Configuration</b>') % (plugin.name))
|
||||
label.set_markup(label.get_label())
|
||||
self.main.pack_start(label, False, False)
|
||||
|
||||
@log_calls('GajimPluginConfigDialog')
|
||||
def run(self, parent=None):
|
||||
self.reparent(parent)
|
||||
self.show_all()
|
||||
result = super(GajimPluginConfigDialog, self).run()
|
||||
self.hide()
|
||||
return result
|
||||
|
|
@ -27,6 +27,7 @@ Base class for implementing plugin.
|
|||
import os
|
||||
|
||||
from plugins.helpers import log_calls
|
||||
from plugins.gui import GajimPluginConfigDialog
|
||||
|
||||
class GajimPlugin(object):
|
||||
'''
|
||||
|
@ -96,28 +97,29 @@ class GajimPlugin(object):
|
|||
|
||||
@log_calls('GajimPlugin')
|
||||
def __init__(self):
|
||||
self.config = Config()
|
||||
self.config = GajimPluginConfig()
|
||||
'''
|
||||
Plug-in configuration dictionary.
|
||||
|
||||
Automatically saved and loaded and plug-in (un)load.
|
||||
|
||||
:type: `plugins.plugin.Config`
|
||||
:type: `plugins.plugin.GajimPluginConfig`
|
||||
'''
|
||||
self.load_config()
|
||||
self.config_dialog = GajimPluginConfigDialog(self)
|
||||
self.init()
|
||||
|
||||
@log_calls('GajimPlugin')
|
||||
def save_config(self):
|
||||
pass
|
||||
self.config.save()
|
||||
|
||||
@log_calls('GajimPlugin')
|
||||
def load_config(self):
|
||||
pass
|
||||
self.config.load()
|
||||
|
||||
@log_calls('GajimPlugin')
|
||||
def __del__(self):
|
||||
self._save_config()
|
||||
self.save_config()
|
||||
|
||||
@log_calls('GajimPlugin')
|
||||
def local_file_path(self, file_name):
|
||||
|
@ -135,5 +137,11 @@ class GajimPlugin(object):
|
|||
def deactivate(self):
|
||||
pass
|
||||
|
||||
class Config(dict):
|
||||
pass
|
||||
class GajimPluginConfig(dict):
|
||||
@log_calls('GajimPluginConfig')
|
||||
def save(self):
|
||||
pass
|
||||
|
||||
@log_calls('GajimPluginConfig')
|
||||
def load(self):
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue