Exemplo n.º 1
0
    def DELETE_current_configuration(self):

        if self.checkbutton_delete_warning.get_active():
            Gdk.threads_enter()
            if not gtk_dialog_question(self.window_root, TEXT_CONFIRM_DELETE_CONFIGURATION, icon=self._paths._small_icon_file):
                Gdk.threads_leave()
                return
            Gdk.threads_leave()

        Gdk.threads_enter()
        self.label_user_message.set_text(TEXT_CONFIGURATION_DELETED)
        Gdk.threads_leave()

        theme_factory._AVAILABLE_THEMES.pop(self.theme.name)

        if os.path.exists(self.theme.path):
            os.remove(self.theme.path)

        if len(theme_factory._AVAILABLE_THEMES.keys()) == 0:
            theme_factory.CREATE_default_profile(self.computer)

        Gdk.threads_enter()
        self.POPULATE_liststore_profiles()
        Gdk.threads_leave()

        AKBLConnection._command('reload_configurations')

        sleep(0.5)

        Gdk.threads_enter()
        self.label_user_message.set_text(' ')
        Gdk.threads_leave()
Exemplo n.º 2
0
    def _on_button_close_clicked(self, data=None):

        #
        # Do not exit if no computer has been set (warn the user)
        #
        if self.label_set_as.get_text() == _EMPTY_MODEL:
            if gtk_dialog_question(None,
                                   _TEXT_NO_COMPUTER_MODEL_WANT_TO_QUIT,
                                   icon=_SOFTWARE_PATHS._small_icon_file):
                return

        #
        # In case that the computer is the same (than previously used), update the file
        #

        if self.__default_computer_model == self._get_default_computer_name():

            for i, _ in enumerate(self.liststore_computer_models):

                iter_row = self.liststore_computer_models.get_iter(i)

                if self.liststore_computer_models.get_value(iter_row, 1):

                    computer_model = self.liststore_computer_models.get_value(
                        iter_row, 0)
                    computer_factory.set_default_computer(computer_model)

                    break

        #
        # Quit the application
        #

        Gtk.main_quit()
Exemplo n.º 3
0
    def _on_button_close_clicked(self, data=None):

        if self.label_set_as.get_text() == _EMPTY_MODEL:
            if gtk_dialog_question(None,
                                   _TEXT_NO_COMPUTER_MODEL_WANT_TO_QUIT,
                                   icon=_SOFTWARE_PATHS._small_icon_file):
                return

        Gtk.main_quit()
Exemplo n.º 4
0
    def on_imagemenuitem_export_activate(self, widget=None, data=None):
        folder_path = gtk_folder_chooser(parent=self.window_root, title=TEXT_CHOOSE_A_FOLDER_TO_EXPORT, icon_path=self._paths._small_icon_file)

        if folder_path:
            new_path = '{}/{}.cfg'.format(folder_path, self.theme.name)

            if os.path.exists(new_path) and not gtk_dialog_question(
                    self.window_root, TEXT_THEME_ALREADY_EXISTS):
                return

            shutil.copy(self.theme.path, new_path)
Exemplo n.º 5
0
    def on_imagemenuitem_import_activate(self, widget=None, data=None):
        file_path = gtk_file_chooser(parent=self.window_root,
                                     title=TEXT_CHOOSE_A_THEME,
                                     icon_path=self._paths._small_icon_file,
                                     filters=(("AKBL theme", '*.cfg'),))

        if file_path:
            new_path = self._paths._profiles_dir + os.path.basename(file_path)

            if os.path.exists(new_path) and not gtk_dialog_question(self.window_root, TEXT_THEME_ALREADY_EXISTS):
                return

            shutil.copy(file_path, new_path)
            theme_factory.load_from_file(new_path, self.computer)
            self.POPULATE_liststore_profiles()