Browse Source

rename entities

PHP-GTK3
yggverse 8 months ago
parent
commit
e4511403ee
  1. 6
      config.json
  2. 34
      src/Entity/Tab/History.php

6
config.json

@ -165,13 +165,13 @@
"visible":true, "visible":true,
"label":"Clear" "label":"Clear"
}, },
"go": "search":
{ {
"visible":true, "visible":true,
"label":"Go" "label":"Search"
} }
}, },
"search": "filter":
{ {
"placeholder":"Search in history..." "placeholder":"Search in history..."
} }

34
src/Entity/Tab/History.php

@ -14,9 +14,9 @@ class History
public \GtkButton $open, public \GtkButton $open,
$clear, $clear,
$go; $search;
public \GtkEntry $search; public \GtkEntry $filter;
public \GtkListStore $list; public \GtkListStore $list;
public \GtkTreeView $treeview; public \GtkTreeView $treeview;
@ -110,14 +110,14 @@ class History
); );
} }
// Search field // Filter field
$this->search = new \GtkEntry; $this->filter = new \GtkEntry;
$this->search->set_placeholder_text( $this->filter->set_placeholder_text(
$this->config->header->search->placeholder $this->config->header->filter->placeholder
); );
$this->search->connect( $this->filter->connect(
'activate', 'activate',
function ($entry) function ($entry)
{ {
@ -128,31 +128,31 @@ class History
); );
$this->header->pack_start( $this->header->pack_start(
$this->search, $this->filter,
true, true,
true, true,
0 0
); );
// Go button // Search button
$this->go = \GtkButton::new_with_label( $this->search = \GtkButton::new_with_label(
$this->config->header->button->go->label $this->config->header->button->search->label
); );
$this->go->connect( $this->search->connect(
'clicked', 'clicked',
function () function ()
{ {
$this->refresh( $this->refresh(
$this->search->get_text() $this->filter->get_text()
); );
} }
); );
if ($this->config->header->button->go->visible) if ($this->config->header->button->search->visible)
{ {
$this->header->add( $this->header->add(
$this->go $this->search
); );
} }
@ -253,7 +253,7 @@ class History
} }
public function refresh( public function refresh(
string $search = '' string $filter = ''
): void ): void
{ {
// Reset previous state // Reset previous state
@ -269,7 +269,7 @@ class History
); );
// Build history list from database records // Build history list from database records
foreach ($this->app->database->getHistory($search) as $record) foreach ($this->app->database->getHistory($filter) as $record)
{ {
$this->list->append( $this->list->append(
[ [

Loading…
Cancel
Save