Philipp Hörist pushed to branch master at gajim / gajim

Commits:

1 changed file:

Changes:

  • gajim/gtk/adhoc.py
    ... ... @@ -137,7 +137,12 @@ class AdHocCommand(Gtk.Assistant):
    137 137
                         if button is not None:
    
    138 138
                             button.show()
    
    139 139
     
    
    140
    -        elif page in (Page.ERROR, Page.COMPLETED):
    
    140
    +        elif page == Page.ERROR:
    
    141
    +            error_page = self.get_nth_page(page)
    
    142
    +            if error_page.show_command_button:
    
    143
    +                self._buttons['commands'].show()
    
    144
    +
    
    145
    +        elif page == Page.COMPLETED:
    
    141 146
                 self._buttons['commands'].show()
    
    142 147
     
    
    143 148
         def _add_page(self, page):
    
    ... ... @@ -155,6 +160,10 @@ class AdHocCommand(Gtk.Assistant):
    155 160
             dataform = None
    
    156 161
             if action == AdHocAction.EXECUTE:
    
    157 162
                 command = self.get_nth_page(current_page).get_selected_command()
    
    163
    +            if command is None:
    
    164
    +                # The commands page should not show if there are no commands,
    
    165
    +                # but if for some reason it does dont fail horribly
    
    166
    +                return
    
    158 167
             else:
    
    159 168
                 command, dataform = self.get_nth_page(current_page).stage_data
    
    160 169
                 if action == AdHocAction.PREV:
    
    ... ... @@ -178,9 +187,19 @@ class AdHocCommand(Gtk.Assistant):
    178 187
     
    
    179 188
         @ensure_not_destroyed
    
    180 189
         def _received_command_list(self, commands):
    
    190
    +        error_text = None
    
    181 191
             if is_error_result(commands):
    
    192
    +            error_text = str(commands)
    
    193
    +
    
    194
    +        elif not commands:
    
    195
    +            error_text = _('No commands available')
    
    196
    +
    
    197
    +        if error_text is not None:
    
    198
    +            self.get_nth_page(Page.ERROR).set_text(error_text)
    
    199
    +            self.get_nth_page(Page.ERROR).show_command_button = False
    
    182 200
                 self.set_current_page(Page.ERROR)
    
    183 201
                 return
    
    202
    +
    
    184 203
             self.get_nth_page(Page.COMMANDS).add_commands(commands)
    
    185 204
             self.set_current_page(Page.COMMANDS)
    
    186 205
     
    
    ... ... @@ -188,6 +207,7 @@ class AdHocCommand(Gtk.Assistant):
    188 207
         def _received_stage(self, stage):
    
    189 208
             if is_error_result(stage):
    
    190 209
                 self.get_nth_page(Page.ERROR).set_text(str(stage))
    
    210
    +            self.get_nth_page(Page.ERROR).show_command_button = True
    
    191 211
                 self.set_current_page(Page.ERROR)
    
    192 212
                 return
    
    193 213
     
    
    ... ... @@ -211,12 +231,6 @@ class AdHocCommand(Gtk.Assistant):
    211 231
         def _on_page_change(self, _assistant, _page):
    
    212 232
             self._set_button_visibility(self.get_current_page())
    
    213 233
     
    
    214
    -    def _on_error(self, error_text):
    
    215
    -        log.info('Show Error page')
    
    216
    -        page = self.get_nth_page(Page.ERROR)
    
    217
    -        page.set_text(error_text)
    
    218
    -        self.set_current_page(Page.ERROR)
    
    219
    -
    
    220 234
         def _on_cancel(self, _widget):
    
    221 235
             self.destroy()
    
    222 236
     
    
    ... ... @@ -443,6 +457,7 @@ class Error(Gtk.Box):
    443 457
             super().__init__(orientation=Gtk.Orientation.VERTICAL)
    
    444 458
             self.set_spacing(12)
    
    445 459
             self.set_homogeneous(True)
    
    460
    +        self._show_command_button = False
    
    446 461
     
    
    447 462
             icon = Gtk.Image.new_from_icon_name('dialog-error-symbolic',
    
    448 463
                                                 Gtk.IconSize.DIALOG)
    
    ... ... @@ -458,3 +473,11 @@ class Error(Gtk.Box):
    458 473
     
    
    459 474
         def set_text(self, text):
    
    460 475
             self._label.set_text(text)
    
    476
    +
    
    477
    +    @property
    
    478
    +    def show_command_button(self):
    
    479
    +        return self._show_command_button
    
    480
    +
    
    481
    +    @show_command_button.setter
    
    482
    +    def show_command_button(self, value):
    
    483
    +        self._show_command_button = value