Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
b4797d25
by Daniel Brötzmann at 2019-11-05T09:34:34Z
2 changed files:
Changes:
| ... | ... | @@ -14,6 +14,25 @@ |
| 14 | 14 |
<property name="icon_name">utilities-terminal-symbolic</property>
|
| 15 | 15 |
</object>
|
| 16 | 16 |
</child>
|
| 17 |
+ <child>
|
|
| 18 |
+ <object class="GtkToggleButton" id="search_toggle">
|
|
| 19 |
+ <property name="visible">True</property>
|
|
| 20 |
+ <property name="can_focus">True</property>
|
|
| 21 |
+ <property name="receives_default">True</property>
|
|
| 22 |
+ <property name="margin_left">6</property>
|
|
| 23 |
+ <signal name="toggled" handler="_on_search_toggled" swapped="no"/>
|
|
| 24 |
+ <child>
|
|
| 25 |
+ <object class="GtkImage">
|
|
| 26 |
+ <property name="visible">True</property>
|
|
| 27 |
+ <property name="can_focus">False</property>
|
|
| 28 |
+ <property name="icon_name">system-search-symbolic</property>
|
|
| 29 |
+ </object>
|
|
| 30 |
+ </child>
|
|
| 31 |
+ </object>
|
|
| 32 |
+ <packing>
|
|
| 33 |
+ <property name="position">1</property>
|
|
| 34 |
+ </packing>
|
|
| 35 |
+ </child>
|
|
| 17 | 36 |
</object>
|
| 18 | 37 |
<object class="GtkPopover" id="popover">
|
| 19 | 38 |
<property name="can_focus">False</property>
|
| ... | ... | @@ -80,18 +99,103 @@ |
| 80 | 99 |
<property name="vexpand">True</property>
|
| 81 | 100 |
<property name="orientation">vertical</property>
|
| 82 | 101 |
<child>
|
| 83 |
- <object class="GtkScrolledWindow" id="scrolled">
|
|
| 84 |
- <property name="height_request">400</property>
|
|
| 102 |
+ <object class="GtkBox">
|
|
| 85 | 103 |
<property name="visible">True</property>
|
| 86 |
- <property name="can_focus">True</property>
|
|
| 87 |
- <property name="shadow_type">in</property>
|
|
| 104 |
+ <property name="can_focus">False</property>
|
|
| 105 |
+ <property name="orientation">vertical</property>
|
|
| 106 |
+ <child>
|
|
| 107 |
+ <object class="GtkRevealer" id="search_revealer">
|
|
| 108 |
+ <property name="visible">True</property>
|
|
| 109 |
+ <property name="can_focus">False</property>
|
|
| 110 |
+ <property name="transition_type">none</property>
|
|
| 111 |
+ <property name="transition_duration">100</property>
|
|
| 112 |
+ <child>
|
|
| 113 |
+ <object class="GtkToolbar">
|
|
| 114 |
+ <property name="visible">True</property>
|
|
| 115 |
+ <property name="can_focus">False</property>
|
|
| 116 |
+ <property name="halign">center</property>
|
|
| 117 |
+ <property name="show_arrow">False</property>
|
|
| 118 |
+ <property name="icon_size">2</property>
|
|
| 119 |
+ <child>
|
|
| 120 |
+ <object class="GtkToolItem">
|
|
| 121 |
+ <property name="visible">True</property>
|
|
| 122 |
+ <property name="can_focus">False</property>
|
|
| 123 |
+ <property name="margin_right">6</property>
|
|
| 124 |
+ <child>
|
|
| 125 |
+ <object class="GtkSearchEntry" id="search_entry">
|
|
| 126 |
+ <property name="visible">True</property>
|
|
| 127 |
+ <property name="can_focus">True</property>
|
|
| 128 |
+ <property name="primary_icon_name">edit-find-symbolic</property>
|
|
| 129 |
+ <property name="primary_icon_activatable">False</property>
|
|
| 130 |
+ <property name="primary_icon_sensitive">False</property>
|
|
| 131 |
+ <property name="placeholder_text" translatable="yes">Start Search...</property>
|
|
| 132 |
+ <signal name="activate" handler="_on_search_activate" swapped="no"/>
|
|
| 133 |
+ </object>
|
|
| 134 |
+ </child>
|
|
| 135 |
+ </object>
|
|
| 136 |
+ <packing>
|
|
| 137 |
+ <property name="expand">False</property>
|
|
| 138 |
+ <property name="homogeneous">True</property>
|
|
| 139 |
+ </packing>
|
|
| 140 |
+ </child>
|
|
| 141 |
+ <child>
|
|
| 142 |
+ <object class="GtkToolButton" id="search_forward">
|
|
| 143 |
+ <property name="visible">True</property>
|
|
| 144 |
+ <property name="can_focus">False</property>
|
|
| 145 |
+ <property name="use_underline">True</property>
|
|
| 146 |
+ <property name="icon_name">go-down-symbolic</property>
|
|
| 147 |
+ <signal name="clicked" handler="_on_search_clicked" swapped="no"/>
|
|
| 148 |
+ </object>
|
|
| 149 |
+ <packing>
|
|
| 150 |
+ <property name="expand">False</property>
|
|
| 151 |
+ <property name="homogeneous">True</property>
|
|
| 152 |
+ </packing>
|
|
| 153 |
+ </child>
|
|
| 154 |
+ <child>
|
|
| 155 |
+ <object class="GtkToolButton" id="search_backward">
|
|
| 156 |
+ <property name="visible">True</property>
|
|
| 157 |
+ <property name="can_focus">False</property>
|
|
| 158 |
+ <property name="use_underline">True</property>
|
|
| 159 |
+ <property name="icon_name">go-up-symbolic</property>
|
|
| 160 |
+ <signal name="clicked" handler="_on_search_clicked" swapped="no"/>
|
|
| 161 |
+ </object>
|
|
| 162 |
+ <packing>
|
|
| 163 |
+ <property name="expand">False</property>
|
|
| 164 |
+ <property name="homogeneous">True</property>
|
|
| 165 |
+ </packing>
|
|
| 166 |
+ </child>
|
|
| 167 |
+ </object>
|
|
| 168 |
+ </child>
|
|
| 169 |
+ </object>
|
|
| 170 |
+ <packing>
|
|
| 171 |
+ <property name="expand">False</property>
|
|
| 172 |
+ <property name="fill">True</property>
|
|
| 173 |
+ <property name="position">0</property>
|
|
| 174 |
+ </packing>
|
|
| 175 |
+ </child>
|
|
| 88 | 176 |
<child>
|
| 89 |
- <object class="GtkTextView" id="textview">
|
|
| 177 |
+ <object class="GtkScrolledWindow" id="scrolled">
|
|
| 178 |
+ <property name="height_request">400</property>
|
|
| 90 | 179 |
<property name="visible">True</property>
|
| 91 | 180 |
<property name="can_focus">True</property>
|
| 92 |
- <property name="editable">False</property>
|
|
| 93 |
- <property name="cursor_visible">False</property>
|
|
| 181 |
+ <property name="shadow_type">in</property>
|
|
| 182 |
+ <child>
|
|
| 183 |
+ <object class="GtkTextView" id="textview">
|
|
| 184 |
+ <property name="visible">True</property>
|
|
| 185 |
+ <property name="can_focus">True</property>
|
|
| 186 |
+ <property name="editable">False</property>
|
|
| 187 |
+ <property name="left_margin">6</property>
|
|
| 188 |
+ <property name="right_margin">6</property>
|
|
| 189 |
+ <property name="top_margin">6</property>
|
|
| 190 |
+ <property name="bottom_margin">6</property>
|
|
| 191 |
+ </object>
|
|
| 192 |
+ </child>
|
|
| 94 | 193 |
</object>
|
| 194 |
+ <packing>
|
|
| 195 |
+ <property name="expand">True</property>
|
|
| 196 |
+ <property name="fill">True</property>
|
|
| 197 |
+ <property name="position">1</property>
|
|
| 198 |
+ </packing>
|
|
| 95 | 199 |
</child>
|
| 96 | 200 |
</object>
|
| 97 | 201 |
<packing>
|
| ... | ... | @@ -122,6 +122,13 @@ class XMLConsoleWindow(Gtk.ApplicationWindow): |
| 122 | 122 |
if (event.get_state() & Gdk.ModifierType.CONTROL_MASK and
|
| 123 | 123 |
event.keyval == Gdk.KEY_Up):
|
| 124 | 124 |
self._on_paste_last()
|
| 125 |
+ if (event.get_state() & Gdk.ModifierType.CONTROL_MASK and
|
|
| 126 |
+ event.keyval == Gdk.KEY_f):
|
|
| 127 |
+ self._ui.search_toggle.set_active(
|
|
| 128 |
+ not self._ui.search_revealer.get_child_revealed())
|
|
| 129 |
+ if event.keyval == Gdk.KEY_F3:
|
|
| 130 |
+ search_str = self._ui.search_entry.get_text()
|
|
| 131 |
+ self._find(search_str, True)
|
|
| 125 | 132 |
|
| 126 | 133 |
def _on_row_activated(self, _listbox, row):
|
| 127 | 134 |
text = row.get_child().get_text()
|
| ... | ... | @@ -201,6 +208,51 @@ class XMLConsoleWindow(Gtk.ApplicationWindow): |
| 201 | 208 |
self._combo.hide()
|
| 202 | 209 |
self._ui.menubutton.hide()
|
| 203 | 210 |
|
| 211 |
+ def _on_search_toggled(self, button):
|
|
| 212 |
+ self._ui.search_revealer.set_reveal_child(button.get_active())
|
|
| 213 |
+ self._ui.search_entry.grab_focus()
|
|
| 214 |
+ |
|
| 215 |
+ def _on_search_activate(self, _widget):
|
|
| 216 |
+ search_str = self._ui.search_entry.get_text()
|
|
| 217 |
+ self._find(search_str, True)
|
|
| 218 |
+ |
|
| 219 |
+ def _on_search_clicked(self, button):
|
|
| 220 |
+ forward = bool(button is self._ui.search_forward)
|
|
| 221 |
+ search_str = self._ui.search_entry.get_text()
|
|
| 222 |
+ self._find(search_str, forward)
|
|
| 223 |
+ |
|
| 224 |
+ def _find(self, search_str, forward):
|
|
| 225 |
+ textbuffer = self._ui.textview.get_buffer()
|
|
| 226 |
+ cursor_mark = textbuffer.get_insert()
|
|
| 227 |
+ current_pos = textbuffer.get_iter_at_mark(cursor_mark)
|
|
| 228 |
+ |
|
| 229 |
+ if current_pos.get_offset() == textbuffer.get_char_count():
|
|
| 230 |
+ current_pos = textbuffer.get_start_iter()
|
|
| 231 |
+ |
|
| 232 |
+ last_pos_mark = textbuffer.get_mark('last_pos')
|
|
| 233 |
+ if last_pos_mark is not None:
|
|
| 234 |
+ current_pos = textbuffer.get_iter_at_mark(last_pos_mark)
|
|
| 235 |
+ |
|
| 236 |
+ if forward:
|
|
| 237 |
+ match = current_pos.forward_search(
|
|
| 238 |
+ search_str,
|
|
| 239 |
+ Gtk.TextSearchFlags.VISIBLE_ONLY |
|
|
| 240 |
+ Gtk.TextSearchFlags.CASE_INSENSITIVE,
|
|
| 241 |
+ None)
|
|
| 242 |
+ else:
|
|
| 243 |
+ current_pos.backward_cursor_position()
|
|
| 244 |
+ match = current_pos.backward_search(
|
|
| 245 |
+ search_str,
|
|
| 246 |
+ Gtk.TextSearchFlags.VISIBLE_ONLY |
|
|
| 247 |
+ Gtk.TextSearchFlags.CASE_INSENSITIVE,
|
|
| 248 |
+ None)
|
|
| 249 |
+ |
|
| 250 |
+ if match is not None:
|
|
| 251 |
+ match_start, match_end = match
|
|
| 252 |
+ textbuffer.select_range(match_start, match_end)
|
|
| 253 |
+ mark = textbuffer.create_mark('last_pos', match_end, True)
|
|
| 254 |
+ self._ui.textview.scroll_to_mark(mark, 0, True, 0.5, 0.5)
|
|
| 255 |
+ |
|
| 204 | 256 |
@staticmethod
|
| 205 | 257 |
def _get_accounts():
|
| 206 | 258 |
accounts = app.get_accounts_sorted()
|