def configure(self, widget, data=None):
        ui = {}
        dbox = Gtk.Dialog(_("Terminator themes"), None, Gtk.DialogFlags.MODAL)

        headers = {"Accept": "application/vnd.github.v3.raw"}
        response = requests.get(self.base_url, headers=headers)

        if response.status_code != 200:
            gerr(_("Failed to get list of available themes"))
            return

        self.themes_from_repo = response.json()["themes"]
        self.profiles = self.terminal.config.list_profiles()

        main_container = Gtk.HBox(spacing=5)
        main_container.pack_start(self._create_themes_grid(ui), True, True,
                                  0)  #Left column
        main_container.pack_start(self._create_settings_grid(ui), True, True,
                                  0)  #Right column

        dbox.vbox.pack_start(main_container, True, True, 0)

        self.dbox = dbox
        dbox.show_all()
        res = dbox.run()

        if res == Gtk.ResponseType.ACCEPT:
            self.terminal.config.save()

        del (self.dbox)
        dbox.destroy()

        return
    def configure(self, widget, data = None):
        ui = {}
        dbox = Gtk.Dialog( _("Terminator themes"), None, Gtk.DialogFlags.MODAL)
        
        headers = { "Accept": "application/vnd.github.v3.raw" }
        response = requests.get(self.base_url, headers=headers)

        if response.status_code != 200:
            gerr(_("Failed to get list of available themes"))
            return
        
        self.themes_from_repo = response.json()["themes"]
        self.profiles = self.terminal.config.list_profiles()

        main_container = Gtk.HBox(spacing=7)
        main_container.pack_start(self._create_themes_list(ui), True, True, 0)
        main_container.pack_start(self._create_settings_grid(ui), True, True, 0)
        dbox.vbox.pack_start(main_container, True, True, 0)

        self.dbox = dbox
        dbox.show_all()
        res = dbox.run()

        if res == Gtk.ResponseType.ACCEPT:
            self.terminal.config.save()

        del(self.dbox)
        dbox.destroy()
        return
Beispiel #3
0
 def on_new(self, button, data):
     (dialog, enabled, name, command) = self._create_command_dialog()
     res = dialog.run()
     item = {}
     if res == Gtk.ResponseType.ACCEPT:
         item['enabled'] = enabled.get_active()
         item['name'] = name.get_text()
         item['command'] = command.get_text()
         if item['name'] == '' or item['command'] == '':
             err = Gtk.MessageDialog(
                 dialog, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR,
                 Gtk.ButtonsType.CLOSE,
                 _("You need to define a name and command"))
             err.run()
             err.destroy()
         else:
             # we have a new command
             store = data['treeview'].get_model()
             iter = store.get_iter_first()
             name_exist = False
             while iter != None:
                 if store.get_value(iter, CC_COL_NAME) == item['name']:
                     name_exist = True
                     break
                 iter = store.iter_next(iter)
             if not name_exist:
                 store.append(
                     (item['enabled'], item['name'], item['command']))
             else:
                 gerr(_("Name *%s* already exist") % item['name'])
     dialog.destroy()
Beispiel #4
0
 def on_new(self, button, data):
   (dialog,enabled,name,command) = self._create_command_dialog()
   res = dialog.run()
   item = {}
   if res == Gtk.ResponseType.ACCEPT:
     item['enabled'] = enabled.get_active()
     item['name'] = name.get_text()
     item['command'] = command.get_text()
     if item['name'] == '' or item['command'] == '':
       err = Gtk.MessageDialog(dialog,
                               Gtk.DialogFlags.MODAL,
                               Gtk.MessageType.ERROR,
                               Gtk.ButtonsType.CLOSE,
                               _("You need to define a name and command")
                             )
       err.run()
       err.destroy()
     else:
       # we have a new command
       store = data['treeview'].get_model()
       iter = store.get_iter_first()
       name_exist = False
       while iter != None:
         if store.get_value(iter,CC_COL_NAME) == item['name']:
           name_exist = True
           break
         iter = store.iter_next(iter)
       if not name_exist:
         store.append((item['enabled'], item['name'], item['command']))
       else:
         gerr(_("Name *%s* already exist") % item['name'])
   dialog.destroy()
Beispiel #5
0
    def configure(self, widget, data=None):
        ui = {}
        dbox = Gtk.Dialog(_("Terminator themes"), None, Gtk.DIALOG_MODAL)

        self.profiles_from_repo = []
        response = requests.get(self.base_url)

        if response.status_code != 200:
            gerr(_("Failed to get list of available themes"))
            return

        for repo in response.json():
            self.profiles_from_repo.append(repo['name'])

        self.profiles = self.terminal.config.list_profiles()

        main_container = Gtk.HBox(spacing=5)
        main_container.pack_start(self._create_themes_list(ui), True, True)
        main_container.pack_start(self._create_settings_grid(ui), True, True,
                                  0)
        dbox.vbox.pack_start(main_container, True, True)

        self.dbox = dbox
        dbox.show_all()
        res = dbox.run()

        if res == Gtk.RESPONSE_ACCEPT:
            self.terminal.config.save()
        del (self.dbox)
        dbox.destroy()

        return
    def on_install(self, button, data):
        treeview = data['treeview']
        selection = treeview.get_selection()
        (store, iter) = selection.get_selected()
        target = store[iter][0]
        widget = self.terminal.get_vte()
        treeview.set_enable_tree_lines(False)

        if not iter:
            return

        headers = {"Accept": "application/vnd.github.v3.raw"}
        response = requests.get(self.base_url + '/' + target + '.config',
                                headers=headers)

        if response.status_code != 200:
            gerr(_("Failed to download selected theme"))
            return

        # Creates a new profile and overwrites the default colors for the new theme
        self.terminal.config.add_profile(target)
        target_data = self.make_dictionary(response.content)
        for k, v in target_data.items():
            if k != 'background_image':
                self.config_base.set_item(k, v[1:-1], target)

        self.terminal.force_set_profile(widget, target)
        self.terminal.config.save()

        # "Remove" button available again
        self.liststore.set_value(iter, 1, False)
        self.on_selection_changed(selection, data)
        treeview.set_enable_tree_lines(True)
    def on_install(self, button, data):
        treeview = data['treeview']
        selection = treeview.get_selection()
        (store, iter) = selection.get_selected()
        target = store[iter][0]
        widget = self.terminal.get_vte()
        treeview.set_enable_tree_lines(False)
        
        if not iter:
            return

    
        headers = { "Accept": "application/vnd.github.v3.raw" }
        response = requests.get(self.base_url+ '/' + target + '.config', headers=headers)
       
        if response.status_code != 200:
            gerr(_("Failed to download selected theme"))
            return

        # Creates a new profile and overwrites the default colors for the new theme
        self.terminal.config.add_profile(target) 
        target_data = self.make_dictionary(response.content)
        for k, v in target_data.items():
            if k != 'background_image':
                 self.config_base.set_item(k, v[1:-1], target)

        self.terminal.force_set_profile(widget, target)
        self.terminal.config.save()

        # "Remove" button available again
        self.liststore.set_value(iter, 1, False)
        self.on_selection_changed(selection, data)
        treeview.set_enable_tree_lines(True)
Beispiel #8
0
    def configure(self, widget, data = None):
       
        ui = {}

        win = Gtk.Window()
        win.set_border_width(10)
        win.set_default_size(700, 400)

        win.set_titlebar(self.make_headerbar(ui))

        # Fill thmmes containers
        self.profiles = self.terminal.config.list_profiles()

        response = requests.get("https://git.io/fxtUa")

        if response.status_code != 200:
            gerr(_("Failed to get list of available themes"))
            return

        dark_themes = self.make_themes_container(ui, filter(lambda x: x['type'] == 'dark', response.json()["themes"]))
        light_themes = self.make_themes_container(ui, filter(lambda x: x['type'] == 'light', response.json()["themes"]))
       
        main_container = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=3)
        main_container.set_homogeneous(False)
        win.add(main_container)

        ui["stack"].add_titled(dark_themes, "check", "Dark themes")
        ui["stack"].add_titled(light_themes, "label", "Light themes")

        # Box to center stack horizontally
      

        # searchContainer = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, halign=Gtk.Align.CENTER)
        # search_entry = Gtk.SearchEntry(max_width_chars=45)
        # search_entry.connect("search-changed", self.on_search_changed, ui)
        # search_entry.show()
        # searchContainer.add(search_entry)
        # ui["search_entry"] = search_entry

        # for i in range(220):

        #     main_container.pack_start(Gtk.Button("test"), True, True, 1)
      
       # main_container.pack_start(searchContainer, False, False, 1)
        main_container.pack_start(ui["stack"], True, True, 1)

        win.show_all()
    def on_edit(self, button, data):
      treeview = data['treeview']
      selection = treeview.get_selection()
      (store, iter) = selection.get_selected()
      
      if not iter:
        return
       
      (dialog,enabled,name,command) = self._create_command_dialog(
                                                enabled_var = store.get_value(iter, CC_COL_ENABLED),
                                                name_var = store.get_value(iter, CC_COL_NAME),
                                                command_var = store.get_value(iter, CC_COL_COMMAND)
                                                                  )
      res = dialog.run()
      item = {}
      if res == Gtk.ResponseType.ACCEPT:
        item['enabled'] = enabled.get_active()
        item['name'] = name.get_text()
        item['command'] = command.get_text()
        if item['name'] == '' or item['command'] == '':
          err = Gtk.MessageDialog(dialog,
                                  Gtk.DialogFlags.MODAL,
                                  Gtk.MessageType.ERROR,
                                  Gtk.ButtonsType.CLOSE,
                                  _("You need to define a name and command")
                                )
          err.run()
          err.destroy()
        else:
          tmpiter = store.get_iter_first()
          name_exist = False
          while tmpiter != None:
            if store.get_path(tmpiter) != store.get_path(iter) and store.get_value(tmpiter,CC_COL_NAME) == item['name']:
              name_exist = True
              break
            tmpiter = store.iter_next(tmpiter)
          if not name_exist:
            store.set(iter,
                      CC_COL_ENABLED,item['enabled'],
                      CC_COL_NAME, item['name'],
                      CC_COL_COMMAND, item['command']
                      )
          else:
            gerr(_("Name *%s* already exist") % item['name'])

      dialog.destroy()
Beispiel #10
0
    def on_edit(self, button, data):
      treeview = data['treeview']
      selection = treeview.get_selection()
      (store, iter) = selection.get_selected()
      
      if not iter:
        return
       
      (dialog,enabled,name,command) = self._create_command_dialog(
                                                enabled_var = store.get_value(iter, CC_COL_ENABLED),
                                                name_var = store.get_value(iter, CC_COL_NAME),
                                                command_var = store.get_value(iter, CC_COL_COMMAND)
                                                                  )
      res = dialog.run()
      item = {}
      if res == Gtk.ResponseType.ACCEPT:
        item['enabled'] = enabled.get_active()
        item['name'] = name.get_text()
        item['command'] = command.get_text()
        if item['name'] == '' or item['command'] == '':
          err = Gtk.MessageDialog(dialog,
                                  Gtk.DialogFlags.MODAL,
                                  Gtk.MessageType.ERROR,
                                  Gtk.ButtonsType.CLOSE,
                                  _("You need to define a name and command")
                                )
          err.run()
          err.destroy()
        else:
          tmpiter = store.get_iter_first()
          name_exist = False
          while tmpiter != None:
            if store.get_path(tmpiter) != store.get_path(iter) and store.get_value(tmpiter,CC_COL_NAME) == item['name']:
              name_exist = True
              break
            tmpiter = store.iter_next(tmpiter)
          if not name_exist:
            store.set(iter,
                      CC_COL_ENABLED,item['enabled'],
                      CC_COL_NAME, item['name'],
                      CC_COL_COMMAND, item['command']
                      )
          else:
            gerr(_("Name *%s* already exist") % item['name'])

      dialog.destroy()
Beispiel #11
0
    def on_new(self, button, data):
      (dialog,ip,user,port,passwd) = self._create_command_dialog()
      res = dialog.run()
      item = {}
      if res == Gtk.ResponseType.ACCEPT:
        item['ip'] = ip.get_text()
        item['user'] = user.get_text()
        item['port'] = port.get_text()
        item['passwd'] = encrypt_passwd(passwd.get_text()) 
        if item['ip'] == '' or item['user'] == '' or item['port'] == '':
          err = Gtk.MessageDialog(dialog,
                                  Gtk.DialogFlags.MODAL,
                                  Gtk.MessageType.ERROR,
                                  Gtk.ButtonsType.CLOSE,
                                  _("You need input ip and user and port")
                                )
          err.run()
          err.destroy()
        else:
          # we have a new command
          filter_store = data['treeview'].get_model()
          store = filter_store.get_model()

          ssh_key = item['user'] + '@' + item['ip']
          ssh_exist = False
          iter = store.get_iter_first()
          while iter != None:
            if store.get_path(iter) != store.get_path(iter) :
              temp_user = store.get_value(iter,CC_COL_USER)
              temp_ip = store.get_value(iter,CC_COL_IP)
              temp_key = temp_user + '@' + temp_ip

              if ssh_key == temp_key:
                ssh_exist = True
                break

            iter = store.iter_next(iter)
          if not ssh_exist:
            store.insert(0, (item['ip'], item['user'], item['port'], nowTime(), item['passwd']))
            self.update_cmd_list(store)
            self._save_config()
          else:
            gerr(_("ssh config *%s* already exist") % ssh_key)
      dialog.destroy()
    def configure(self, widget, data=None):
        ui = {}

        dbox = Gtk.Dialog(_("Terminator themes"), None, Gtk.DialogFlags.MODAL,
                          (_("_Close"), Gtk.ResponseType.ACCEPT))

        self.liststore = Gtk.ListStore(str, bool)

        profiles_from_repo = []
        response = requests.get(self.base_url)

        if response.status_code != 200:
            gerr(_("Failed to get list of available themes"))
            return

        for repo in response.json():
            profiles_from_repo.append(repo['name'])

        profiles = self.terminal.config.list_profiles()

        # Set add/remove buttons availability
        for profile in profiles_from_repo:
            profile = profile.split(".")
            if profile[0] in profiles:
                self.liststore.append([profile[0], False])
            else:
                self.liststore.append([profile[0], True])

        treeview = Gtk.TreeView(self.liststore)

        selection = treeview.get_selection()

        selection.set_mode(Gtk.SelectionMode.SINGLE)
        selection.connect("changed", self.on_selection_changed, ui)
        ui['treeview'] = treeview

        renderer_text = Gtk.CellRendererText()
        column_text = Gtk.TreeViewColumn("Theme", renderer_text, text=0)
        treeview.append_column(column_text)

        scroll_window = Gtk.ScrolledWindow()
        scroll_window.set_size_request(500, 250)
        scroll_window.set_policy(Gtk.PolicyType.AUTOMATIC,
                                 Gtk.PolicyType.AUTOMATIC)
        scroll_window.add_with_viewport(treeview)

        hbox = Gtk.HBox()
        hbox.pack_start(scroll_window, True, True, 0)
        dbox.vbox.pack_start(hbox, True, True, 0)

        button_box = Gtk.VBox()

        button = Gtk.Button(_("Install"))
        button_box.pack_start(button, False, True, 0)
        button.connect("clicked", self.on_install, ui)
        button.set_sensitive(False)
        ui['button_install'] = button

        button = Gtk.Button(_("Remove"))
        button_box.pack_start(button, False, True, 0)
        button.connect("clicked", self.on_uninstall, ui)
        button.set_sensitive(False)
        ui['button_uninstall'] = button

        hbox.pack_start(button_box, False, True, 0)
        self.dbox = dbox
        dbox.show_all()
        res = dbox.run()
        if res == Gtk.ResponseType.ACCEPT:
            self.terminal.config.save()
        del (self.dbox)
        dbox.destroy()
        return
Beispiel #13
0
    def on_edit(self, button, data):
      treeview = data['treeview']
      selection = treeview.get_selection()
      (store_filter, filter_iter) = selection.get_selected()
      
      store = store_filter.get_model()
      iter = store_filter.convert_iter_to_child_iter(filter_iter)

      if not iter:
        return
      
      old_ssh_key =  store.get_value(iter, CC_COL_USER) + '@' + store.get_value(iter, CC_COL_IP)
      (dialog,ip,user,port,passwd) = self._create_command_dialog(
                                                ip_var = store.get_value(iter, CC_COL_IP),
                                                user_var = store.get_value(iter, CC_COL_USER),
                                                port_var = store.get_value(iter, CC_COL_PORT),
                                                passwd_var = decrypt_passwd(store.get_value(iter, CC_COL_PASSWD))
                                                                  )
      res = dialog.run()
      item = {}
      if res == Gtk.ResponseType.ACCEPT:
        item['ip'] = ip.get_text()
        item['user'] = user.get_text()
        item['port'] = port.get_text()
        item['passwd'] = encrypt_passwd(passwd.get_text())
        if item['ip'] == '' or item['user'] == '' or item['port'] == '':
          err = Gtk.MessageDialog(dialog,
                                  Gtk.DialogFlags.MODAL,
                                  Gtk.MessageType.ERROR,
                                  Gtk.ButtonsType.CLOSE,
                                  _("You need input ip and user and port")
                                )
          err.run()
          err.destroy()
        else:
          ssh_key = item['user'] + '@' + item['ip']
          ssh_exist = False

          tmpiter = store.get_iter_first()
          while tmpiter != None:
            if store.get_path(tmpiter) != store.get_path(iter) :
              temp_user = store.get_value(tmpiter,CC_COL_USER)
              temp_ip = store.get_value(tmpiter,CC_COL_IP)
              temp_key = temp_user + '@' + temp_ip

              if ssh_key == temp_key:
                ssh_exist = True
                break

            tmpiter = store.iter_next(tmpiter)

          if not ssh_exist:
            store.set(iter,
                      CC_COL_IP,   item['ip'],
                      CC_COL_USER, item['user'],
                      CC_COL_PORT, item['port'],
                      CC_COL_TIME, nowTime(),
                      CC_COL_PASSWD, item['passwd']
                      )

            self.update_cmd_list(store)
            self._save_config()
          else:
            gerr(_("ssh config *%s* already exist") % ssh_key)

      dialog.destroy()
    def configure(self, widget, data = None):
        ui = {}
   
        dbox = Gtk.Dialog(
                        _("Terminator themes"),
                        None,
                        Gtk.DialogFlags.MODAL,
                        (
                            
                            _("_Close"), Gtk.ResponseType.ACCEPT
                        )
                        )

        self.liststore = Gtk.ListStore(str, bool)

        profiles_from_repo = []
        response = requests.get(self.base_url)
        
        if response.status_code != 200:
            gerr(_("Failed to get list of available themes"))
            return

        for repo in response.json():
            profiles_from_repo.append(repo['name'])
        
       
        profiles = self.terminal.config.list_profiles()

        # Set add/remove buttons availability
        for profile in profiles_from_repo:
            profile = profile.split(".")
            if profile[0] in profiles:
                self.liststore.append([profile[0], False])
            else:
                self.liststore.append([profile[0], True])
        

        treeview = Gtk.TreeView(self.liststore)

        selection = treeview.get_selection()
       
        selection.set_mode(Gtk.SelectionMode.SINGLE)
        selection.connect("changed", self.on_selection_changed, ui)
        ui['treeview'] = treeview

        renderer_text = Gtk.CellRendererText()
        column_text = Gtk.TreeViewColumn("Theme", renderer_text, text=0)
        treeview.append_column(column_text)


        scroll_window = Gtk.ScrolledWindow()
        scroll_window.set_size_request(500, 250)
        scroll_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        scroll_window.add_with_viewport(treeview)

        hbox = Gtk.HBox()
        hbox.pack_start(scroll_window, True, True, 0)
        dbox.vbox.pack_start(hbox, True, True, 0)

        button_box = Gtk.VBox()
        
        button = Gtk.Button(_("Install"))
        button_box.pack_start(button, False, True, 0)
        button.connect("clicked", self.on_install, ui) 
        button.set_sensitive(False)
        ui['button_install'] = button

        button = Gtk.Button(_("Remove"))
        button_box.pack_start(button, False, True, 0)
        button.connect("clicked", self.on_uninstall, ui) 
        button.set_sensitive(False)
        ui['button_uninstall'] = button

        hbox.pack_start(button_box, False, True, 0)
        self.dbox = dbox
        dbox.show_all()
        res = dbox.run()
        if res == Gtk.ResponseType.ACCEPT:
            self.terminal.config.save()
        del(self.dbox)
        dbox.destroy()
        return