* Make default theme unchangeable
* cleanup and bugfix for sensitive color table
This commit is contained in:
parent
ecc54114f7
commit
c145c2ce36
|
@ -408,7 +408,7 @@ Chat Banner</property>
|
|||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTable" id="table36">
|
||||
<widget class="GtkTable" id="theme_options_table">
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">9</property>
|
||||
<property name="n_columns">2</property>
|
||||
|
|
|
@ -50,6 +50,7 @@ class GajimThemesWindow:
|
|||
self.italic_togglebutton = self.xml.get_widget('italic_togglebutton')
|
||||
self.themes_tree = self.xml.get_widget('themes_treeview')
|
||||
self.theme_options_vbox = self.xml.get_widget('theme_options_vbox')
|
||||
self.theme_options_table = self.xml.get_widget('theme_options_table')
|
||||
self.colorbuttons = {}
|
||||
for chatstate in ('inactive', 'composing', 'paused', 'gone',
|
||||
'muc_msg', 'muc_directed_msg'):
|
||||
|
@ -67,6 +68,7 @@ class GajimThemesWindow:
|
|||
self.current_theme = gajim.config.get('roster_theme')
|
||||
self.no_update = False
|
||||
self.fill_themes_treeview()
|
||||
self.select_active_theme()
|
||||
self.current_option = self.options[0]
|
||||
self.set_theme_options(self.current_theme, self.current_option)
|
||||
|
||||
|
@ -90,6 +92,11 @@ class GajimThemesWindow:
|
|||
new_name = new_name.decode('utf-8')
|
||||
if old_name == new_name:
|
||||
return
|
||||
if old_name == 'default':
|
||||
dialogs.ErrorDialog(
|
||||
_('You cannot make changes to the default theme'),
|
||||
_('Please create a clean new theme with your desired name.'))
|
||||
return
|
||||
new_config_name = new_name.replace(' ', '_')
|
||||
if new_config_name in gajim.config.get_per('themes'):
|
||||
return
|
||||
|
@ -110,28 +117,31 @@ class GajimThemesWindow:
|
|||
self.current_theme = new_name
|
||||
|
||||
def fill_themes_treeview(self):
|
||||
self.xml.get_widget('remove_button').set_sensitive(False)
|
||||
self.theme_options_vbox.set_sensitive(False)
|
||||
model = self.themes_tree.get_model()
|
||||
model.clear()
|
||||
for config_theme in gajim.config.get_per('themes'):
|
||||
theme = config_theme.replace('_', ' ')
|
||||
iter = model.append([theme])
|
||||
if gajim.config.get('roster_theme') == config_theme:
|
||||
self.themes_tree.get_selection().select_iter(iter)
|
||||
self.xml.get_widget('remove_button').set_sensitive(True)
|
||||
self.theme_options_vbox.set_sensitive(True)
|
||||
|
||||
def select_active_theme(self):
|
||||
model = self.themes_tree.get_model()
|
||||
iter = model.get_iter_root()
|
||||
active_theme = gajim.config.get('roster_theme')
|
||||
active_theme = gajim.config.get('roster_theme').replace('_', ' ')
|
||||
while iter:
|
||||
theme = model[iter][0]
|
||||
if theme == active_theme:
|
||||
self.themes_tree.get_selection().select_iter(iter)
|
||||
self.xml.get_widget('remove_button').set_sensitive(True)
|
||||
self.theme_options_vbox.set_sensitive(True)
|
||||
self.theme_options_table.set_sensitive(True)
|
||||
if active_theme == 'default':
|
||||
self.xml.get_widget('remove_button').set_sensitive(False)
|
||||
self.theme_options_vbox.set_sensitive(False)
|
||||
self.theme_options_table.set_sensitive(False)
|
||||
else:
|
||||
self.xml.get_widget('remove_button').set_sensitive(True)
|
||||
self.theme_options_vbox.set_sensitive(True)
|
||||
self.theme_options_table.set_sensitive(True)
|
||||
break
|
||||
iter = model.iter_next(iter)
|
||||
|
||||
|
@ -140,12 +150,19 @@ class GajimThemesWindow:
|
|||
selected = self.themes_tree.get_selection().get_selected_rows()
|
||||
if not iter or selected[1] == []:
|
||||
self.theme_options_vbox.set_sensitive(False)
|
||||
self.theme_options_table.set_sensitive(False)
|
||||
return
|
||||
self.xml.get_widget('remove_button').set_sensitive(True)
|
||||
self.theme_options_vbox.set_sensitive(True)
|
||||
self.current_theme = model.get_value(iter, 0).decode('utf-8')
|
||||
self.current_theme = self.current_theme.replace(' ', '_')
|
||||
self.set_theme_options(self.current_theme)
|
||||
if self.current_theme == 'default':
|
||||
self.xml.get_widget('remove_button').set_sensitive(False)
|
||||
self.theme_options_vbox.set_sensitive(False)
|
||||
self.theme_options_table.set_sensitive(False)
|
||||
else:
|
||||
self.xml.get_widget('remove_button').set_sensitive(True)
|
||||
self.theme_options_vbox.set_sensitive(True)
|
||||
self.theme_options_table.set_sensitive(True)
|
||||
|
||||
def on_add_button_clicked(self, widget):
|
||||
model = self.themes_tree.get_model()
|
||||
|
@ -173,6 +190,8 @@ class GajimThemesWindow:
|
|||
_('Please first choose another for your current theme.'))
|
||||
return
|
||||
self.theme_options_vbox.set_sensitive(False)
|
||||
self.theme_options_table.set_sensitive(False)
|
||||
self.xml.get_widget('remove_button').set_sensitive(False)
|
||||
gajim.config.del_per('themes', self.current_theme)
|
||||
model.remove(iter)
|
||||
|
||||
|
|
Loading…
Reference in New Issue