Esempio n. 1
0
 def on_action_edit_activate(self, action):
     """Edit the selected service"""
     selected_row = get_treeview_selected_row(self.ui.tvw_services)
     if selected_row:
         name = self.model.get_key(selected_row)
         description = self.model.get_description(selected_row)
         command = self.model.get_command(selected_row)
         terminal = self.model.get_terminal(selected_row)
         icon = self.model.get_icon(selected_row)
         selected_iter = self.model.get_iter(name)
         dialog = UIServiceDetail(self.ui.dialog_services, self.model)
         if dialog.show(default_name=name,
                        default_description=description,
                        default_command=command,
                        default_terminal=terminal,
                        default_icon=icon,
                        title=_('Edit service'),
                        treeiter=selected_iter) == Gtk.ResponseType.OK:
             # Update values
             self.model.set_data(
                 selected_iter,
                 ServiceInfo(name=dialog.name,
                             description=dialog.description,
                             command=dialog.command,
                             terminal=dialog.terminal,
                             icon=dialog.icon))
         dialog.destroy()
Esempio n. 2
0
 def on_action_add_activate(self, action):
     """Add a new service"""
     dialog = UIServiceDetail(self.ui.dialog_services, self.model)
     if dialog.show(default_name='',
                    default_description='',
                    default_command='',
                    default_terminal=False,
                    default_icon='',
                    title=_('Add new service'),
                    treeiter=None) == Gtk.ResponseType.OK:
         self.model.add_data(
             ServiceInfo(name=dialog.name,
                         description=dialog.description,
                         command=dialog.command,
                         terminal=dialog.terminal,
                         icon=dialog.icon))
     dialog.destroy()