@@ -146,6 +146,7 @@ class GPasteApplet extends Applet.IconApplet {
146146 this . _appletSettings . bind ( "display-searchbar" , "displaySearchBar" , this . _onDisplaySettingsUpdated ) ;
147147 this . _appletSettings . bind ( "display-gpaste-ui" , "displayGPasteUI" , this . _onDisplaySettingsUpdated ) ;
148148 this . _appletSettings . bind ( "display-empty-history" , "displayEmptyHistory" , this . _onDisplaySettingsUpdated ) ;
149+ this . _appletSettings . bind ( "reverse-history-order" , "reverseHistory" , this . _onDisplaySettingsUpdated ) ;
149150
150151 this . _appletSettings . bind ( "kb-show-history" , "kbShowHistory" , this . _onKeybindingUpdated ) ;
151152 this . _onKeybindingUpdated ( ) ;
@@ -254,6 +255,8 @@ class GPasteApplet extends Applet.IconApplet {
254255
255256 this . msepBottom2 . actor . visible = this . displayGPasteUI ;
256257 this . mitemUI . actor . visible = this . displayGPasteUI ;
258+
259+ this . _onSettingsUpdated ( ) ;
257260 }
258261
259262 /*
@@ -273,10 +276,6 @@ class GPasteApplet extends Applet.IconApplet {
273276 }
274277 }
275278
276- if ( this . mitemSearch . entry . get_text ( ) == '' ) {
277- this . _historyItems [ 0 ] . actor . set_style ( "font-weight: bold;" ) ;
278- }
279-
280279 this . refresh ( oldSize ) ;
281280 }
282281
@@ -352,6 +351,8 @@ class GPasteApplet extends Applet.IconApplet {
352351 * Refresh the history items
353352 */
354353 refresh ( startID ) {
354+ this . _historyItems . forEach ( item => item . actor . set_style ( null ) ) ;
355+
355356 if ( this . _searchResults . length > 0 ) { // Search field isn't empty
356357 this . search ( this . mitemSearch . getText ( ) ) ;
357358 } else {
@@ -364,7 +365,8 @@ class GPasteApplet extends Applet.IconApplet {
364365 }
365366
366367 for ( let i = startID ; i < size ; ++ i ) {
367- this . _historyItems [ i ] . setIndex ( i ) ;
368+ const idx = this . reverseHistory ? ( size - 1 - i ) : i ;
369+ this . _historyItems [ i ] . setIndex ( idx ) ;
368370 }
369371 for ( let i = size ; i < maxSize ; ++ i ) {
370372 this . _historyItems [ i ] . setIndex ( - 1 ) ;
@@ -374,6 +376,9 @@ class GPasteApplet extends Applet.IconApplet {
374376 this . mitemHistoryIsEmpty . actor . show ( ) ;
375377 } else {
376378 this . mitemHistoryIsEmpty . actor . hide ( ) ;
379+ const highlightPos = this . reverseHistory ? size - 1 : 0 ;
380+ if ( highlightPos >= 0 && highlightPos < this . _historyItems . length )
381+ this . _historyItems [ highlightPos ] . actor . set_style ( "font-weight: bold;" ) ;
377382 }
378383 } ) ;
379384 }
@@ -397,14 +402,16 @@ class GPasteApplet extends Applet.IconApplet {
397402 results = maxSize ;
398403 }
399404
405+ const ordered = this . reverseHistory ? this . _searchResults . slice ( ) . reverse ( ) : this . _searchResults ;
406+
400407 this . _historyItems . slice ( 0 , results ) . forEach ( ( item , index ) => {
401- item . setUuid ( this . _searchResults [ index ] ) ;
408+ item . setUuid ( ordered [ index ] ) ;
402409 } ) ;
403410 this . _historyItems . slice ( results , maxSize ) . forEach ( ( item , index ) => {
404411 item . setIndex ( - 1 ) ;
405412 } ) ;
406413
407- this . _historyItems [ 0 ] . actor . set_style ( null ) ;
414+ this . _historyItems . forEach ( item => item . actor . set_style ( null ) ) ;
408415
409416 if ( results == 0 ) { // There aren't any results, display "(No results)"
410417 this . mitemNoSearchResults . actor . show ( ) ;
@@ -417,7 +424,6 @@ class GPasteApplet extends Applet.IconApplet {
417424
418425 this . _searchResults = [ ] ;
419426 this . refresh ( 0 ) ;
420- this . _historyItems [ 0 ] . actor . set_style ( "font-weight: bold;" ) ;
421427 }
422428 }
423429
@@ -572,6 +578,17 @@ class GPasteApplet extends Applet.IconApplet {
572578 this . mitemTrack . setToggleState ( state ) ;
573579 }
574580
581+ /*
582+ * Called whenever settings change that affect how the history is presented
583+ */
584+ _onSettingsUpdated ( ) {
585+ if ( this . _searchResults . length > 0 ) {
586+ this . search ( this . mitemSearch . getText ( ) ) ;
587+ } else {
588+ this . refresh ( 0 ) ;
589+ }
590+ }
591+
575592 //
576593 // Overrides
577594 // ---------------------------------------------------------------------------------
0 commit comments