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

Commits:

6 changed files:

Changes:

  • gajim/chat_control_base.py
    ... ... @@ -396,6 +396,9 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
    396 396
                 self.emoticons_button.get_popover().show()
    
    397 397
                 return Gdk.EVENT_STOP
    
    398 398
     
    
    399
    +        if action == 'copy-text':
    
    400
    +            self.conv_textview.tv.emit('copy-clipboard')
    
    401
    +
    
    399 402
             return Gdk.EVENT_PROPAGATE
    
    400 403
     
    
    401 404
         def add_actions(self):
    

  • gajim/common/config.py
    ... ... @@ -295,6 +295,7 @@ class Config:
    295 295
             'muclumbus_api_jid': [opt_str, 'rodrigo.de.mucobedo@dreckshal.de'],
    
    296 296
             'muclumbus_api_http_uri': [opt_str, 'https://search.jabbercat.org/api/1.0/search'],
    
    297 297
             'muclumbus_api_pref': [opt_str, 'http', _('API Preferences. Possible values: \'http\', \'iq\'')],
    
    298
    +        'auto_copy': [opt_bool, True, _('Selecting text will copy it to the clipboard')],
    
    298 299
         }, {})  # type: Tuple[Dict[str, List[Any]], Dict[Any, Any]]
    
    299 300
     
    
    300 301
         __options_per_key = {
    

  • gajim/data/gui/preferences_window.ui
    ... ... @@ -565,6 +565,60 @@
    565 565
                 <property name="border_width">18</property>
    
    566 566
                 <property name="orientation">vertical</property>
    
    567 567
                 <property name="spacing">6</property>
    
    568
    +            <child>
    
    569
    +              <object class="GtkFrame">
    
    570
    +                <property name="visible">True</property>
    
    571
    +                <property name="can_focus">False</property>
    
    572
    +                <property name="label_xalign">0</property>
    
    573
    +                <property name="shadow_type">none</property>
    
    574
    +                <child>
    
    575
    +                  <object class="GtkAlignment">
    
    576
    +                    <property name="visible">True</property>
    
    577
    +                    <property name="can_focus">False</property>
    
    578
    +                    <child>
    
    579
    +                      <object class="GtkBox">
    
    580
    +                        <property name="visible">True</property>
    
    581
    +                        <property name="can_focus">False</property>
    
    582
    +                        <property name="orientation">vertical</property>
    
    583
    +                        <child>
    
    584
    +                          <object class="GtkCheckButton" id="auto_copy">
    
    585
    +                            <property name="label" translatable="yes">Enable auto copy</property>
    
    586
    +                            <property name="can_focus">True</property>
    
    587
    +                            <property name="receives_default">False</property>
    
    588
    +                            <property name="tooltip_text" translatable="yes">If enabled, selecting Text will be copied to the clipboard, otherwise you can copy text with CTRL + SHIFT + C</property>
    
    589
    +                            <property name="halign">start</property>
    
    590
    +                            <property name="use_underline">True</property>
    
    591
    +                            <property name="draw_indicator">True</property>
    
    592
    +                            <signal name="toggled" handler="on_auto_copy_toggled" swapped="no"/>
    
    593
    +                          </object>
    
    594
    +                          <packing>
    
    595
    +                            <property name="expand">False</property>
    
    596
    +                            <property name="fill">True</property>
    
    597
    +                            <property name="position">0</property>
    
    598
    +                          </packing>
    
    599
    +                        </child>
    
    600
    +                      </object>
    
    601
    +                    </child>
    
    602
    +                  </object>
    
    603
    +                </child>
    
    604
    +                <child type="label">
    
    605
    +                  <object class="GtkLabel">
    
    606
    +                    <property name="visible">True</property>
    
    607
    +                    <property name="can_focus">False</property>
    
    608
    +                    <property name="label" translatable="yes">General</property>
    
    609
    +                    <style>
    
    610
    +                      <class name="bold"/>
    
    611
    +                      <class name="margin-top6"/>
    
    612
    +                    </style>
    
    613
    +                  </object>
    
    614
    +                </child>
    
    615
    +              </object>
    
    616
    +              <packing>
    
    617
    +                <property name="expand">False</property>
    
    618
    +                <property name="fill">True</property>
    
    619
    +                <property name="position">0</property>
    
    620
    +              </packing>
    
    621
    +            </child>
    
    568 622
                 <child>
    
    569 623
                   <object class="GtkFrame">
    
    570 624
                     <property name="visible">True</property>
    
    ... ... @@ -799,7 +853,7 @@
    799 853
                   <packing>
    
    800 854
                     <property name="expand">False</property>
    
    801 855
                     <property name="fill">True</property>
    
    802
    -                <property name="position">0</property>
    
    856
    +                <property name="position">1</property>
    
    803 857
                   </packing>
    
    804 858
                 </child>
    
    805 859
                 <child>
    
    ... ... @@ -893,7 +947,7 @@
    893 947
                   <packing>
    
    894 948
                     <property name="expand">False</property>
    
    895 949
                     <property name="fill">True</property>
    
    896
    -                <property name="position">1</property>
    
    950
    +                <property name="position">2</property>
    
    897 951
                   </packing>
    
    898 952
                 </child>
    
    899 953
               </object>
    

  • gajim/gtk/htmltextview.py
    ... ... @@ -831,10 +831,26 @@ class HtmlTextView(Gtk.TextView):
    831 831
             self.plugin_modified = False
    
    832 832
             self._cursor_changed = False
    
    833 833
     
    
    834
    +        self.connect('button-release-event', self._on_button_release)
    
    834 835
             if standalone:
    
    835 836
                 self.connect('query-tooltip', self._query_tooltip)
    
    836 837
                 self.create_tags()
    
    837 838
     
    
    839
    +    @staticmethod
    
    840
    +    def _on_button_release(textview, event):
    
    841
    +        if event.button == 1:
    
    842
    +            # Left Mouse button
    
    843
    +
    
    844
    +            if not app.config.get('auto_copy'):
    
    845
    +                return Gdk.EVENT_PROPAGATE
    
    846
    +
    
    847
    +            if not textview.get_buffer().get_has_selection():
    
    848
    +                return Gdk.EVENT_PROPAGATE
    
    849
    +            selected = textview.get_selected_text()
    
    850
    +            clipboard = textview.get_clipboard(Gdk.SELECTION_CLIPBOARD)
    
    851
    +            clipboard.set_text(selected, -1)
    
    852
    +        return Gdk.EVENT_PROPAGATE
    
    853
    +
    
    838 854
         def create_tags(self):
    
    839 855
             color = app.css_config.get_value('.gajim-url', StyleAttr.COLOR)
    
    840 856
     
    

  • gajim/gtk/preferences.py
    ... ... @@ -123,6 +123,12 @@ class Preferences(Gtk.ApplicationWindow):
    123 123
             self._ui.sort_by_show_in_muc_checkbutton.set_active(st)
    
    124 124
     
    
    125 125
             ### Chat tab ###
    
    126
    +        ## General Settings
    
    127
    +
    
    128
    +        # Enable auto copy
    
    129
    +        st = app.config.get('auto_copy')
    
    130
    +        self._ui.auto_copy.set_active(st)
    
    131
    +
    
    126 132
             ## Chat Settings
    
    127 133
             # Use speller
    
    128 134
             if app.is_installed('GSPELL'):
    
    ... ... @@ -539,6 +545,9 @@ class Preferences(Gtk.ApplicationWindow):
    539 545
                 ctrl.draw_roster()
    
    540 546
     
    
    541 547
         ### Chat tab ###
    
    548
    +    def on_auto_copy_toggled(self, widget):
    
    549
    +        self.on_checkbutton_toggled(widget, 'auto_copy')
    
    550
    +
    
    542 551
         def on_speller_checkbutton_toggled(self, widget):
    
    543 552
             active = widget.get_active()
    
    544 553
             app.config.set('use_speller', active)
    

  • gajim/message_window.py
    ... ... @@ -182,6 +182,7 @@ class MessageWindow:
    182 182
                 ('switch-tab-7', ['<Alt>7', '<Alt>KP_7']),
    
    183 183
                 ('switch-tab-8', ['<Alt>8', '<Alt>KP_8']),
    
    184 184
                 ('switch-tab-9', ['<Alt>9', '<Alt>KP_9']),
    
    185
    +            ('copy-text', ['<Control><Shift>c']),
    
    185 186
             ]
    
    186 187
     
    
    187 188
             disabled_for_emacs = (