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

Commits:

4 changed files:

Changes:

  • gajim/data/style/gajim.css
    ... ... @@ -330,3 +330,11 @@ button.flat.link { padding: 0; border: 0; }
    330 330
     #NotificationPopupTitle {
    
    331 331
         font-weight: bold;
    
    332 332
     }
    
    333
    +
    
    334
    +
    
    335
    +popover.combo list { min-width: 200px; margin: 12px;}
    
    336
    +popover.combo { padding: 0px; }
    
    337
    +popover.combo list { border-style: none; background-color: transparent; }
    
    338
    +popover.combo list > row { padding: 0px 12px 0px 12px; min-height: 50px; }
    
    339
    +popover.combo list > row:not(:last-child) { border-bottom: 1px solid alpha(#cdc7c2, 0.5); }
    
    340
    +popover.combo scrollbar.vertical { padding-top: 2px; padding-bottom: 2px; }

  • gajim/gtk/accounts.py
    ... ... @@ -736,9 +736,10 @@ class AdvancedPage(GenericSettingPage):
    736 736
                         SettingType.ACCOUNT_CONFIG, 'autoauth',
    
    737 737
                         desc=_('Automatically accept all contact requests')),
    
    738 738
     
    
    739
    -            Setting(SettingKind.COMBO, _('Filetransfer Preference'),
    
    739
    +            Setting(SettingKind.POPOVER, _('Filetransfer Preference'),
    
    740 740
                         SettingType.ACCOUNT_CONFIG, 'filetransfer_preference',
    
    741
    -                    props={'combo_items': ['httpupload', 'jingle']},
    
    741
    +                    props={'entries': {'httpupload': _('Upload Files'),
    
    742
    +                                       'jingle': _('Send Files Directly')}},
    
    742 743
                         desc=_('Preferred file transfer mechanism for '
    
    743 744
                                'file drag&drop on a chat window'))
    
    744 745
                 ]
    

  • gajim/gtk/const.py
    ... ... @@ -58,6 +58,7 @@ class SettingKind(IntEnum):
    58 58
         CHANGEPASSWORD = 11
    
    59 59
         COMBO = 12
    
    60 60
         COLOR = 13
    
    61
    +    POPOVER = 14
    
    61 62
     
    
    62 63
     
    
    63 64
     @unique
    

  • gajim/gtk/settings.py
    ... ... @@ -98,6 +98,7 @@ class SettingsBox(Gtk.ListBox):
    98 98
                 SettingKind.HOSTNAME: CutstomHostnameSetting,
    
    99 99
                 SettingKind.CHANGEPASSWORD: ChangePasswordSetting,
    
    100 100
                 SettingKind.COMBO: ComboSetting,
    
    101
    +            SettingKind.POPOVER: PopoverSetting,
    
    101 102
             }
    
    102 103
     
    
    103 104
             if extend is not None:
    
    ... ... @@ -545,6 +546,77 @@ class LoginSetting(DialogSetting):
    545 546
             self.set_activatable(not anonym)
    
    546 547
     
    
    547 548
     
    
    549
    +class PopoverSetting(GenericSetting):
    
    550
    +
    
    551
    +    __gproperties__ = {
    
    552
    +        "setting-value": (str, 'Dummy', '', '',
    
    553
    +                          GObject.ParamFlags.READWRITE),}
    
    554
    +
    
    555
    +    def __init__(self, *args, entries):
    
    556
    +        GenericSetting.__init__(self, *args)
    
    557
    +
    
    558
    +        box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
    
    559
    +                      spacing=12)
    
    560
    +        box.set_halign(Gtk.Align.END)
    
    561
    +
    
    562
    +        self._current_label = Gtk.Label()
    
    563
    +        self._current_label.set_valign(Gtk.Align.CENTER)
    
    564
    +        image = Gtk.Image.new_from_icon_name('pan-down-symbolic',
    
    565
    +                                             Gtk.IconSize.MENU)
    
    566
    +        image.set_valign(Gtk.Align.CENTER)
    
    567
    +
    
    568
    +        box.add(self._current_label)
    
    569
    +        box.add(image)
    
    570
    +
    
    571
    +        menu_listbox = Gtk.ListBox()
    
    572
    +        menu_listbox.set_selection_mode(Gtk.SelectionMode.NONE)
    
    573
    +        for value, label in entries.items():
    
    574
    +            menu_listbox.add(PopoverRow(label, value))
    
    575
    +        menu_listbox.connect('row-activated', self._on_menu_row_activated)
    
    576
    +
    
    577
    +        scrolled_window = Gtk.ScrolledWindow()
    
    578
    +        scrolled_window.set_propagate_natural_height(True)
    
    579
    +        scrolled_window.set_propagate_natural_width(True)
    
    580
    +        scrolled_window.set_max_content_height(400)
    
    581
    +        scrolled_window.set_policy(Gtk.PolicyType.NEVER,
    
    582
    +                                   Gtk.PolicyType.AUTOMATIC)
    
    583
    +        scrolled_window.add(menu_listbox)
    
    584
    +        scrolled_window.show_all()
    
    585
    +
    
    586
    +        self._popover = Gtk.Popover()
    
    587
    +        self._popover.get_style_context().add_class('combo')
    
    588
    +        self._popover.set_relative_to(image)
    
    589
    +        self._popover.set_position(Gtk.PositionType.BOTTOM)
    
    590
    +        self._popover.add(scrolled_window)
    
    591
    +
    
    592
    +        self.setting_box.pack_end(box, True, True, 0)
    
    593
    +
    
    594
    +        self._current_label.set_text(entries.get(self.setting_value, ''))
    
    595
    +
    
    596
    +        self.show_all()
    
    597
    +
    
    598
    +    def _on_menu_row_activated(self, listbox, row):
    
    599
    +        listbox.unselect_all()
    
    600
    +        self._current_label.set_text(row.label)
    
    601
    +        self._popover.popdown()
    
    602
    +
    
    603
    +        self.set_value(row.value)
    
    604
    +
    
    605
    +    def on_row_activated(self):
    
    606
    +        self._popover.popup()
    
    607
    +
    
    608
    +
    
    609
    +class PopoverRow(Gtk.ListBoxRow):
    
    610
    +    def __init__(self, label, value):
    
    611
    +        Gtk.ListBoxRow.__init__(self)
    
    612
    +        self.label = label
    
    613
    +        self.value = value
    
    614
    +
    
    615
    +        label = Gtk.Label(label=label)
    
    616
    +        label.set_xalign(0)
    
    617
    +        self.add(label)
    
    618
    +
    
    619
    +
    
    548 620
     class ComboSetting(GenericSetting):
    
    549 621
     
    
    550 622
         __gproperties__ = {