diff options
Diffstat (limited to 'src/view/Zenity.php')
-rw-r--r-- | src/view/Zenity.php | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/view/Zenity.php b/src/view/Zenity.php index a04b794..04c9221 100644 --- a/src/view/Zenity.php +++ b/src/view/Zenity.php | |||
@@ -13,7 +13,7 @@ abstract class ZenityCmd | |||
13 | protected $width = 300; | 13 | protected $width = 300; |
14 | protected $height = 200; // recalculée en fonction du contenu, vaut au minimum 150 | 14 | protected $height = 200; // recalculée en fonction du contenu, vaut au minimum 150 |
15 | 15 | ||
16 | protected function __construct($text, array $rows = []) // $rows est optionnel | 16 | protected function __construct(string $text, array $rows = []) // $rows est optionnel |
17 | { | 17 | { |
18 | $this->text = $text; | 18 | $this->text = $text; |
19 | $this->rows= $rows; | 19 | $this->rows= $rows; |
@@ -31,7 +31,7 @@ abstract class ZenityCmd | |||
31 | 31 | ||
32 | class ZenityList extends ZenityCmd | 32 | class ZenityList extends ZenityCmd |
33 | { | 33 | { |
34 | public function __construct($text, array $rows) | 34 | public function __construct(string $text, array $rows) |
35 | { | 35 | { |
36 | $this->command_type = ' --list'; | 36 | $this->command_type = ' --list'; |
37 | parent::__construct($text, $rows); | 37 | parent::__construct($text, $rows); |
@@ -39,15 +39,17 @@ class ZenityList extends ZenityCmd | |||
39 | $this->command .= ' --width=' . $this->width; | 39 | $this->command .= ' --width=' . $this->width; |
40 | $this->command .= ' --height=' . $this->height; | 40 | $this->command .= ' --height=' . $this->height; |
41 | $this->command .= ' --hide-header'; // ligne inutile, il y a déjà le --text | 41 | $this->command .= ' --hide-header'; // ligne inutile, il y a déjà le --text |
42 | self::one_column_zenity_list($this->rows); | 42 | self::oneColumnZenityList($this->rows); |
43 | } | 43 | } |
44 | 44 | ||
45 | public function set_entries($rows_set) // variable renseignée après la construction | 45 | // cas ou $this->rows est renseignée après |
46 | public function setEntries(array $rows_set) | ||
46 | { | 47 | { |
47 | $this->rows = $rows_set; | 48 | $this->rows = $rows_set; |
48 | } | 49 | } |
49 | 50 | ||
50 | private function one_column_zenity_list($rows) | 51 | // cas où on veut une seule colonne |
52 | private function oneColumnZenityList(array $rows) | ||
51 | { | 53 | { |
52 | $output = ' --column=""'; | 54 | $output = ' --column=""'; |
53 | foreach($rows as $entry) | 55 | foreach($rows as $entry) |
@@ -56,6 +58,8 @@ class ZenityList extends ZenityCmd | |||
56 | } | 58 | } |
57 | $this->command .= $output; | 59 | $this->command .= $output; |
58 | } | 60 | } |
61 | |||
62 | // cas où on veut plusieurs colonnes, le remplissage est horizontal, oui c'est tordu! | ||
59 | } | 63 | } |
60 | 64 | ||
61 | class ZenityQuestion extends ZenityCmd | 65 | class ZenityQuestion extends ZenityCmd |
@@ -70,6 +74,8 @@ class ZenityQuestion extends ZenityCmd | |||
70 | } | 74 | } |
71 | } | 75 | } |
72 | 76 | ||
77 | // note: le formulaire renvoie une chaine avecdes pipes | entre les zones de texte (qui peuvent être vides) | ||
78 | // si on clique sur 'Annuler', renvoie une chaine vide | ||
73 | class ZenityForms extends ZenityCmd | 79 | class ZenityForms extends ZenityCmd |
74 | { | 80 | { |
75 | public function __construct($text, array $rows) | 81 | public function __construct($text, array $rows) |
@@ -77,10 +83,10 @@ class ZenityForms extends ZenityCmd | |||
77 | $this->command_type = ' --forms'; | 83 | $this->command_type = ' --forms'; |
78 | parent::__construct($text, $rows); | 84 | parent::__construct($text, $rows); |
79 | //$this->height = 80 + count($this->rows) * 25; // à tester, mais devrait produire le rendu attendu | 85 | //$this->height = 80 + count($this->rows) * 25; // à tester, mais devrait produire le rendu attendu |
80 | self::entries_zenity_forms($this->rows); | 86 | self::entriesZenityForms($this->rows); |
81 | } | 87 | } |
82 | 88 | ||
83 | private function entries_zenity_forms($entries) | 89 | private function entriesZenityForms($entries) |
84 | { | 90 | { |
85 | $output = ''; | 91 | $output = ''; |
86 | foreach($entries as $one_entry) | 92 | foreach($entries as $one_entry) |