* 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>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkTable" id="table36">
|
<widget class="GtkTable" id="theme_options_table">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="n_rows">9</property>
|
<property name="n_rows">9</property>
|
||||||
<property name="n_columns">2</property>
|
<property name="n_columns">2</property>
|
||||||
|
|
|
@ -50,6 +50,7 @@ class GajimThemesWindow:
|
||||||
self.italic_togglebutton = self.xml.get_widget('italic_togglebutton')
|
self.italic_togglebutton = self.xml.get_widget('italic_togglebutton')
|
||||||
self.themes_tree = self.xml.get_widget('themes_treeview')
|
self.themes_tree = self.xml.get_widget('themes_treeview')
|
||||||
self.theme_options_vbox = self.xml.get_widget('theme_options_vbox')
|
self.theme_options_vbox = self.xml.get_widget('theme_options_vbox')
|
||||||
|
self.theme_options_table = self.xml.get_widget('theme_options_table')
|
||||||
self.colorbuttons = {}
|
self.colorbuttons = {}
|
||||||
for chatstate in ('inactive', 'composing', 'paused', 'gone',
|
for chatstate in ('inactive', 'composing', 'paused', 'gone',
|
||||||
'muc_msg', 'muc_directed_msg'):
|
'muc_msg', 'muc_directed_msg'):
|
||||||
|
@ -67,6 +68,7 @@ class GajimThemesWindow:
|
||||||
self.current_theme = gajim.config.get('roster_theme')
|
self.current_theme = gajim.config.get('roster_theme')
|
||||||
self.no_update = False
|
self.no_update = False
|
||||||
self.fill_themes_treeview()
|
self.fill_themes_treeview()
|
||||||
|
self.select_active_theme()
|
||||||
self.current_option = self.options[0]
|
self.current_option = self.options[0]
|
||||||
self.set_theme_options(self.current_theme, self.current_option)
|
self.set_theme_options(self.current_theme, self.current_option)
|
||||||
|
|
||||||
|
@ -90,6 +92,11 @@ class GajimThemesWindow:
|
||||||
new_name = new_name.decode('utf-8')
|
new_name = new_name.decode('utf-8')
|
||||||
if old_name == new_name:
|
if old_name == new_name:
|
||||||
return
|
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(' ', '_')
|
new_config_name = new_name.replace(' ', '_')
|
||||||
if new_config_name in gajim.config.get_per('themes'):
|
if new_config_name in gajim.config.get_per('themes'):
|
||||||
return
|
return
|
||||||
|
@ -110,28 +117,31 @@ class GajimThemesWindow:
|
||||||
self.current_theme = new_name
|
self.current_theme = new_name
|
||||||
|
|
||||||
def fill_themes_treeview(self):
|
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 = self.themes_tree.get_model()
|
||||||
model.clear()
|
model.clear()
|
||||||
for config_theme in gajim.config.get_per('themes'):
|
for config_theme in gajim.config.get_per('themes'):
|
||||||
theme = config_theme.replace('_', ' ')
|
theme = config_theme.replace('_', ' ')
|
||||||
iter = model.append([theme])
|
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):
|
def select_active_theme(self):
|
||||||
model = self.themes_tree.get_model()
|
model = self.themes_tree.get_model()
|
||||||
iter = model.get_iter_root()
|
iter = model.get_iter_root()
|
||||||
active_theme = gajim.config.get('roster_theme')
|
active_theme = gajim.config.get('roster_theme').replace('_', ' ')
|
||||||
while iter:
|
while iter:
|
||||||
theme = model[iter][0]
|
theme = model[iter][0]
|
||||||
if theme == active_theme:
|
if theme == active_theme:
|
||||||
self.themes_tree.get_selection().select_iter(iter)
|
self.themes_tree.get_selection().select_iter(iter)
|
||||||
self.xml.get_widget('remove_button').set_sensitive(True)
|
self.xml.get_widget('remove_button').set_sensitive(True)
|
||||||
self.theme_options_vbox.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
|
break
|
||||||
iter = model.iter_next(iter)
|
iter = model.iter_next(iter)
|
||||||
|
|
||||||
|
@ -140,12 +150,19 @@ class GajimThemesWindow:
|
||||||
selected = self.themes_tree.get_selection().get_selected_rows()
|
selected = self.themes_tree.get_selection().get_selected_rows()
|
||||||
if not iter or selected[1] == []:
|
if not iter or selected[1] == []:
|
||||||
self.theme_options_vbox.set_sensitive(False)
|
self.theme_options_vbox.set_sensitive(False)
|
||||||
|
self.theme_options_table.set_sensitive(False)
|
||||||
return
|
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 = model.get_value(iter, 0).decode('utf-8')
|
||||||
self.current_theme = self.current_theme.replace(' ', '_')
|
self.current_theme = self.current_theme.replace(' ', '_')
|
||||||
self.set_theme_options(self.current_theme)
|
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):
|
def on_add_button_clicked(self, widget):
|
||||||
model = self.themes_tree.get_model()
|
model = self.themes_tree.get_model()
|
||||||
|
@ -173,6 +190,8 @@ class GajimThemesWindow:
|
||||||
_('Please first choose another for your current theme.'))
|
_('Please first choose another for your current theme.'))
|
||||||
return
|
return
|
||||||
self.theme_options_vbox.set_sensitive(False)
|
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)
|
gajim.config.del_per('themes', self.current_theme)
|
||||||
model.remove(iter)
|
model.remove(iter)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue