Daniel Brötzmann pushed to branch master at gajim / gajim

Commits:

2 changed files:

Changes:

  • gajim/data/gui/search_view.ui
    ... ... @@ -235,7 +235,7 @@ after:yyyy-mm-dd</property>
    235 235
             <property name="can-focus">True</property>
    
    236 236
             <property name="receives-default">False</property>
    
    237 237
             <property name="halign">center</property>
    
    238
    -        <property name="active">True</property>
    
    238
    +        <property name="active">False</property>
    
    239 239
             <property name="draw-indicator">True</property>
    
    240 240
           </object>
    
    241 241
           <packing>
    

  • gajim/gtk/search_view.py
    ... ... @@ -60,7 +60,6 @@ def __init__(self) -> None:
    60 60
             self._account: Optional[str] = None
    
    61 61
             self._jid: Optional[JID] = None
    
    62 62
             self._results_iterator: Optional[Iterator[SearchLogRow]] = None
    
    63
    -        self._scope: str = 'everywhere'
    
    64 63
     
    
    65 64
             self._first_date: Optional[datetime] = None
    
    66 65
             self._last_date: Optional[datetime] = None
    
    ... ... @@ -155,16 +154,17 @@ def _on_search(self, entry: Gtk.Entry) -> None:
    155 154
     
    
    156 155
             everywhere = self._ui.search_checkbutton.get_active()
    
    157 156
             context = self._account is not None and self._jid is not None
    
    157
    +        if not context:
    
    158
    +            # Started search without context -> show in UI
    
    159
    +            self._ui.search_checkbutton.set_active(True)
    
    158 160
     
    
    159 161
             if not context or everywhere:
    
    160
    -            self._scope = 'everywhere'
    
    161 162
                 self._results_iterator = app.storage.archive.search_all_logs(
    
    162 163
                     text,
    
    163 164
                     from_users=from_filters,
    
    164 165
                     before=before_filters,
    
    165 166
                     after=after_filters)
    
    166 167
             else:
    
    167
    -            self._scope = 'contact'
    
    168 168
                 self._results_iterator = app.storage.archive.search_log(
    
    169 169
                     self._account,
    
    170 170
                     self._jid,
    
    ... ... @@ -193,18 +193,13 @@ def _add_results(self) -> None:
    193 193
             accounts = self._get_accounts()
    
    194 194
             assert self._results_iterator is not None
    
    195 195
             for msg in itertools.islice(self._results_iterator, 25):
    
    196
    -            if self._scope == 'everywhere':
    
    197
    -                archive_jid = app.storage.archive.get_jid_from_id(msg.jid_id)
    
    198
    -                if archive_jid is None:
    
    199
    -                    continue
    
    200
    -                result_row = ResultRow(
    
    201
    -                    msg,
    
    202
    -                    accounts[msg.account_id],
    
    203
    -                    JID.from_string(archive_jid.jid))
    
    204
    -            else:
    
    205
    -                assert self._account is not None
    
    206
    -                assert self._jid is not None
    
    207
    -                result_row = ResultRow(msg, self._account, self._jid)
    
    196
    +            archive_jid = app.storage.archive.get_jid_from_id(msg.jid_id)
    
    197
    +            if archive_jid is None:
    
    198
    +                continue
    
    199
    +            result_row = ResultRow(
    
    200
    +                msg,
    
    201
    +                accounts[msg.account_id],
    
    202
    +                JID.from_string(archive_jid.jid))
    
    208 203
     
    
    209 204
                 self._ui.results_listbox.add(result_row)
    
    210 205
     
    
    ... ... @@ -217,24 +212,24 @@ def _on_edge_reached(self,
    217 212
             self._add_results()
    
    218 213
     
    
    219 214
         def _update_calendar(self) -> None:
    
    220
    -        if self._scope == 'everywhere':
    
    215
    +        if self._account is None and self._jid is None:
    
    221 216
                 self._ui.calendar_button.set_sensitive(False)
    
    222
    -        else:
    
    223
    -            self._ui.calendar_button.set_sensitive(True)
    
    217
    +            return
    
    224 218
     
    
    225
    -            first_log = app.storage.archive.get_first_history_timestamp(
    
    226
    -                self._account, self._jid)
    
    227
    -            if first_log is None:
    
    228
    -                return
    
    229
    -            self._first_date = self._get_date_from_timestamp(first_log)
    
    230
    -            last_log = app.storage.archive.get_last_history_timestamp(
    
    231
    -                self._account, self._jid)
    
    232
    -            if last_log is None:
    
    233
    -                return
    
    234
    -            self._last_date = self._get_date_from_timestamp(last_log)
    
    219
    +        self._ui.calendar_button.set_sensitive(True)
    
    235 220
     
    
    236
    -            month = gtk_month(self._last_date.month)
    
    237
    -            self._ui.calendar.select_month(month, self._last_date.year)
    
    221
    +        first_log = app.storage.archive.get_first_history_timestamp(
    
    222
    +            self._account, self._jid)
    
    223
    +        if first_log is None:
    
    224
    +            return
    
    225
    +        self._first_date = self._get_date_from_timestamp(first_log)
    
    226
    +        last_log = app.storage.archive.get_last_history_timestamp(
    
    227
    +            self._account, self._jid)
    
    228
    +        if last_log is None:
    
    229
    +            return
    
    230
    +        self._last_date = self._get_date_from_timestamp(last_log)
    
    231
    +        month = gtk_month(self._last_date.month)
    
    232
    +        self._ui.calendar.select_month(month, self._last_date.year)
    
    238 233
     
    
    239 234
         def _on_month_changed(self, calendar: Gtk.Calendar) -> None:
    
    240 235
             # Mark days with history in calendar
    
    ... ... @@ -361,13 +356,6 @@ def set_focus(self) -> None:
    361 356
         def set_context(self, account: Optional[str], jid: Optional[JID]) -> None:
    
    362 357
             self._account = account
    
    363 358
             self._jid = jid
    
    364
    -        everywhere = bool(jid is None)
    
    365
    -        self._ui.search_checkbutton.set_active(everywhere)
    
    366
    -        context = account is not None and jid is not None
    
    367
    -        if not context or everywhere:
    
    368
    -            self._scope = 'everywhere'
    
    369
    -        else:
    
    370
    -            self._scope = 'contact'
    
    371 359
             self._update_calendar()
    
    372 360
     
    
    373 361