Philipp Hörist pushed to branch master at gajim / gajim

Commits:

3 changed files:

Changes:

  • gajim/common/helpers.py
    ... ... @@ -1592,3 +1592,19 @@ def version_condition(current_version, required_version):
    1592 1592
         if V(current_version) < V(required_version):
    
    1593 1593
             return False
    
    1594 1594
         return True
    
    1595
    +
    
    1596
    +def get_available_emoticon_themes():
    
    1597
    +    emoticons_themes = []
    
    1598
    +    emoticons_data_path = os.path.join(app.DATA_DIR, 'emoticons')
    
    1599
    +
    
    1600
    +    folders = os.listdir(emoticons_data_path)
    
    1601
    +    if os.path.isdir(app.MY_EMOTS_PATH):
    
    1602
    +        folders += os.listdir(app.MY_EMOTS_PATH)
    
    1603
    +
    
    1604
    +    for theme in folders:
    
    1605
    +        theme_path = os.path.join(
    
    1606
    +            emoticons_data_path, theme, 'emoticons_theme.py')
    
    1607
    +        if os.path.exists(theme_path):
    
    1608
    +            emoticons_themes.append(theme)
    
    1609
    +    emoticons_themes.sort()
    
    1610
    +    return emoticons_themes

  • gajim/config.py
    ... ... @@ -143,29 +143,20 @@ class PreferencesWindow:
    143 143
     
    
    144 144
             # emoticons
    
    145 145
             emoticons_combobox = self.xml.get_object('emoticons_combobox')
    
    146
    -        emoticons_list = os.listdir(os.path.join(app.DATA_DIR, 'emoticons'))
    
    147
    -        # user themes
    
    148
    -        if os.path.isdir(app.MY_EMOTS_PATH):
    
    149
    -            emoticons_list += os.listdir(app.MY_EMOTS_PATH)
    
    150
    -        emoticons_list.sort()
    
    151
    -        renderer_text = Gtk.CellRendererText()
    
    152
    -        emoticons_combobox.pack_start(renderer_text, True)
    
    153
    -        emoticons_combobox.add_attribute(renderer_text, 'text', 0)
    
    154
    -        model = Gtk.ListStore(str)
    
    155
    -        emoticons_combobox.set_model(model)
    
    156
    -        l = [_('Disabled')]
    
    157
    -        for dir_ in emoticons_list:
    
    158
    -            if not os.path.isdir(os.path.join(app.DATA_DIR, 'emoticons', dir_)) \
    
    159
    -            and not os.path.isdir(os.path.join(app.MY_EMOTS_PATH, dir_)) :
    
    160
    -                continue
    
    161
    -            if dir_ != '.svn':
    
    162
    -                l.append(dir_)
    
    163
    -        for i in range(len(l)):
    
    164
    -            model.append([l[i]])
    
    165
    -            if app.config.get('emoticons_theme') == l[i]:
    
    166
    -                emoticons_combobox.set_active(i)
    
    167
    -        if not app.config.get('emoticons_theme'):
    
    168
    -            emoticons_combobox.set_active(0)
    
    146
    +        emoticon_themes = helpers.get_available_emoticon_themes()
    
    147
    +
    
    148
    +        emoticons_combobox.append_text(_('Disabled'))
    
    149
    +        for theme in emoticon_themes:
    
    150
    +            emoticons_combobox.append_text(theme)
    
    151
    +
    
    152
    +        config_theme = app.config.get('emoticons_theme')
    
    153
    +        if config_theme not in emoticon_themes:
    
    154
    +            # Fallback theme
    
    155
    +            config_theme = 'font-emoticons'
    
    156
    +            app.config.set('emoticons_theme', 'font-emoticons')
    
    157
    +        emoticons_combobox.set_id_column(0)
    
    158
    +        emoticons_combobox.set_active_id(config_theme)
    
    159
    +
    
    169 160
     
    
    170 161
             # Set default for single window type
    
    171 162
             choices = c_config.opt_one_window_types
    

  • gajim/data/gui/preferences_window.ui
    1 1
     <?xml version="1.0" encoding="UTF-8"?>
    
    2
    -<!-- Generated with glade 3.20.0 -->
    
    2
    +<!-- Generated with glade 3.20.2 -->
    
    3 3
     <interface>
    
    4 4
       <requires lib="gtk+" version="3.12"/>
    
    5 5
       <object class="GtkAdjustment" id="adjustment1">
    
    ... ... @@ -516,17 +516,6 @@
    516 516
                               </packing>
    
    517 517
                             </child>
    
    518 518
                             <child>
    
    519
    -                          <object class="GtkComboBox" id="emoticons_combobox">
    
    520
    -                            <property name="visible">True</property>
    
    521
    -                            <property name="can_focus">False</property>
    
    522
    -                            <signal name="changed" handler="on_emoticons_combobox_changed" swapped="no"/>
    
    523
    -                          </object>
    
    524
    -                          <packing>
    
    525
    -                            <property name="left_attach">1</property>
    
    526
    -                            <property name="top_attach">0</property>
    
    527
    -                          </packing>
    
    528
    -                        </child>
    
    529
    -                        <child>
    
    530 519
                               <object class="GtkCheckButton" id="show_avatar_in_tabs_checkbutton">
    
    531 520
                                 <property name="label" translatable="yes">Show avatar in chat tabs</property>
    
    532 521
                                 <property name="visible">True</property>
    
    ... ... @@ -542,6 +531,17 @@
    542 531
                                 <property name="width">2</property>
    
    543 532
                               </packing>
    
    544 533
                             </child>
    
    534
    +                        <child>
    
    535
    +                          <object class="GtkComboBoxText" id="emoticons_combobox">
    
    536
    +                            <property name="visible">True</property>
    
    537
    +                            <property name="can_focus">False</property>
    
    538
    +                            <signal name="changed" handler="on_emoticons_combobox_changed" swapped="no"/>
    
    539
    +                          </object>
    
    540
    +                          <packing>
    
    541
    +                            <property name="left_attach">1</property>
    
    542
    +                            <property name="top_attach">0</property>
    
    543
    +                          </packing>
    
    544
    +                        </child>
    
    545 545
                           </object>
    
    546 546
                         </child>
    
    547 547
                         <child type="label">
    
    ... ... @@ -2888,5 +2888,8 @@ to discover one from server.</property>
    2888 2888
             </child>
    
    2889 2889
           </object>
    
    2890 2890
         </child>
    
    2891
    +    <child type="titlebar">
    
    2892
    +      <placeholder/>
    
    2893
    +    </child>
    
    2891 2894
       </object>
    
    2892 2895
     </interface>