コード例 #1
0
ファイル: preferences.php プロジェクト: Krzysiu/SVGnife
function savePreferencesDialog()
{
    global $dialogPreferences, $glade, $config, $radioGroup, $i18n, $gui;
    // Display preview
    $config['displayPreview'] = $dialogPreferences->get_widget('_prefDisplayPreview')->get_active();
    gtShow($glade->get_widget('_previewArea'), $config['displayPreview']);
    // Check if temporary directory is accessible
    $config['tempDirectory'] = $dialogPreferences->get_widget('_prefTempPath')->get_filenames()[0];
    if (!is_dir($config['tempDirectory'])) {
        setPreferencesNoticeBox($i18n->_('prefErrTempDir404'), $gui['CNoticeBarErrBG']);
        return false;
    }
    $accessTest = $config['tempDirectory'] . DIRECTORY_SEPARATOR . 'tmpTest';
    if (!touch($accessTest)) {
        setPreferencesNoticeBox($i18n->_('prefErrTempDirAccess', $config['tempDirectory']), $gui['CNoticeBarErrBG']);
        return false;
    }
    unlink($accessTest);
    unset($accessTest);
    $inkPath = $dialogPreferences->get_widget('_prefInkscapePath')->get_filenames();
    $config['inkscapePath'] = isset($inkPath[0]) ? $inkPath[0] : '';
    unset($inkPath);
    if (!file_exists($config['inkscapePath']) && $config['displayPreview']) {
        setPreferencesNoticeBox($i18n->_('prefErrInkscapeAccess'), $gui['CNoticeBarErrBG']);
        return false;
    }
    // Display info bar
    $config['displayInfobar'] = $dialogPreferences->get_widget('_prefDisplayInfobar')->get_active();
    gtShow($glade->get_widget('_infoBar'), $config['displayInfobar']);
    // Display navigation bar
    $config['displayNavbar'] = $dialogPreferences->get_widget('_prefDisplayNavbar')->get_active();
    gtShow($glade->get_widget('_navBar'), $config['displayNavbar']);
    // Hide upload button if upload is disabled
    $config['enableUpload'] = $dialogPreferences->get_widget('_prefUploadEnable')->get_active();
    gtShow($glade->get_widget('_btnUpload'), $config['enableUpload']);
    $i = 0;
    foreach ($radioGroup['toolbarStyle'] as $radio) {
        if ($dialogPreferences->get_widget($radio)->get_active()) {
            $config['toolbarStyle'] = $i;
            break;
        }
        $i++;
    }
    $glade->get_widget('_toolbar')->set_toolbar_style($config['toolbarStyle']);
    $i = 0;
    foreach ($radioGroup['previewArea'] as $radio) {
        if ($dialogPreferences->get_widget($radio)->get_active()) {
            $config['previewArea'] = $i;
            break;
        }
        $i++;
    }
    // Active language
    preg_match('/\\(([a-zA-Z_]*)\\)/', $dialogPreferences->get_widget('_prefLanguageSelect')->get_active_text(), $matches);
    $config['language'] = $matches[1];
    unset($matches);
    $config['uploadUsername'] = trim(gtGetText($dialogPreferences->get_widget('_prefUploadUsername')));
    $config['uploadAPIKey'] = trim(gtGetText($dialogPreferences->get_widget('_prefUploadAPIKey')));
    if ($config['enableUpload']) {
        $uploadCredWarn = '';
        if (!$config['uploadUsername']) {
            $uploadCredWarn .= '• ' . $i18n->_('prefErrNoUsername') . "\n";
        }
        if (!$config['uploadAPIKey']) {
            $uploadCredWarn .= '• ' . $i18n->_('prefErrNoAPIKey');
        } elseif (!ctype_xdigit($config['uploadAPIKey']) || strlen($config['uploadAPIKey']) !== 32) {
            $uploadCredWarn .= '• ' . $i18n->_('prefErrWrongAPIKey');
        }
        if ($uploadCredWarn) {
            $uploadCredWarn = trim($uploadCredWarn) . "\n" . $i18n->_('prefErrUploadCredentials');
            setPreferencesNoticeBox($uploadCredWarn, $gui['CNoticeBarErrBG']);
            return false;
        }
    }
    $config['NSFWTagToFlag'] = $dialogPreferences->get_widget('_prefUploadNSFW')->get_active();
    saveConfigFile();
    // @functions.php
    $dialogPreferences->get_widget('_dialogPreferences')->destroy();
}
コード例 #2
0
ファイル: SVGnife.php プロジェクト: Krzysiu/SVGnife
function spinnerToggle($state)
{
    global $_previewSpinner, $_preview;
    gtShow($_preview, !$state);
    gtShow($_previewSpinner, $state);
    gtSpin($_previewSpinner, $state);
}