diff --git a/gajim/common/helpers.py b/gajim/common/helpers.py index d5fc04bd00c742852b74b0f40731fa55f9fee07c..4d8ed27af6447f26697fb0312a4151ef4c726305 100644 --- a/gajim/common/helpers.py +++ b/gajim/common/helpers.py @@ -1592,3 +1592,19 @@ def version_condition(current_version, required_version): if V(current_version) < V(required_version): return False return True + +def get_available_emoticon_themes(): + emoticons_themes = [] + emoticons_data_path = os.path.join(app.DATA_DIR, 'emoticons') + + folders = os.listdir(emoticons_data_path) + if os.path.isdir(app.MY_EMOTS_PATH): + folders += os.listdir(app.MY_EMOTS_PATH) + + for theme in folders: + theme_path = os.path.join( + emoticons_data_path, theme, 'emoticons_theme.py') + if os.path.exists(theme_path): + emoticons_themes.append(theme) + emoticons_themes.sort() + return emoticons_themes diff --git a/gajim/config.py b/gajim/config.py index 1fab60f1b0cc901d82cced7d9b37a160c854029a..8a718df9827382df4ec53001143209c2ef64184b 100644 --- a/gajim/config.py +++ b/gajim/config.py @@ -143,29 +143,20 @@ class PreferencesWindow: # emoticons emoticons_combobox = self.xml.get_object('emoticons_combobox') - emoticons_list = os.listdir(os.path.join(app.DATA_DIR, 'emoticons')) - # user themes - if os.path.isdir(app.MY_EMOTS_PATH): - emoticons_list += os.listdir(app.MY_EMOTS_PATH) - emoticons_list.sort() - renderer_text = Gtk.CellRendererText() - emoticons_combobox.pack_start(renderer_text, True) - emoticons_combobox.add_attribute(renderer_text, 'text', 0) - model = Gtk.ListStore(str) - emoticons_combobox.set_model(model) - l = [_('Disabled')] - for dir_ in emoticons_list: - if not os.path.isdir(os.path.join(app.DATA_DIR, 'emoticons', dir_)) \ - and not os.path.isdir(os.path.join(app.MY_EMOTS_PATH, dir_)) : - continue - if dir_ != '.svn': - l.append(dir_) - for i in range(len(l)): - model.append([l[i]]) - if app.config.get('emoticons_theme') == l[i]: - emoticons_combobox.set_active(i) - if not app.config.get('emoticons_theme'): - emoticons_combobox.set_active(0) + emoticon_themes = helpers.get_available_emoticon_themes() + + emoticons_combobox.append_text(_('Disabled')) + for theme in emoticon_themes: + emoticons_combobox.append_text(theme) + + config_theme = app.config.get('emoticons_theme') + if config_theme not in emoticon_themes: + # Fallback theme + config_theme = 'font-emoticons' + app.config.set('emoticons_theme', 'font-emoticons') + emoticons_combobox.set_id_column(0) + emoticons_combobox.set_active_id(config_theme) + # Set default for single window type choices = c_config.opt_one_window_types diff --git a/gajim/data/gui/preferences_window.ui b/gajim/data/gui/preferences_window.ui index 101c4f255b99dd3426ba488b6714e648a45ecb47..0121805df9a8fa4c1a0b30a15996b08413a11f73 100644 --- a/gajim/data/gui/preferences_window.ui +++ b/gajim/data/gui/preferences_window.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.20.0 --> +<!-- Generated with glade 3.20.2 --> <interface> <requires lib="gtk+" version="3.12"/> <object class="GtkAdjustment" id="adjustment1"> @@ -515,17 +515,6 @@ <property name="top_attach">1</property> </packing> </child> - <child> - <object class="GtkComboBox" id="emoticons_combobox"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <signal name="changed" handler="on_emoticons_combobox_changed" swapped="no"/> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - </packing> - </child> <child> <object class="GtkCheckButton" id="show_avatar_in_tabs_checkbutton"> <property name="label" translatable="yes">Show avatar in chat tabs</property> @@ -542,6 +531,17 @@ <property name="width">2</property> </packing> </child> + <child> + <object class="GtkComboBoxText" id="emoticons_combobox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <signal name="changed" handler="on_emoticons_combobox_changed" swapped="no"/> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> </object> </child> <child type="label"> @@ -2888,5 +2888,8 @@ to discover one from server.</property> </child> </object> </child> + <child type="titlebar"> + <placeholder/> + </child> </object> </interface>