Esempio n. 1
0
function showPreferencesDialog()
{
    global $dialogPreferences, $config, $radioGroup, $i18n, $langList, $gui;
    $dialogPreferences = new GladeXML(gtTranslateGlade('dialogPreferences'));
    $_btnSave = $dialogPreferences->get_widget('_btnSave');
    $_btnCancel = $dialogPreferences->get_widget('_btnCancel');
    $_btnRecognizeInkscape = $dialogPreferences->get_widget('_btnRecognizeInkscape');
    $_noticeLabel = $dialogPreferences->get_widget('_noticeLabel');
    $_prefDisplayPreview = $dialogPreferences->get_widget('_prefDisplayPreview');
    $_prefLanguageSelect = $dialogPreferences->get_widget('_prefLanguageSelect');
    $_prefUploadEnable = $dialogPreferences->get_widget('_prefUploadEnable');
    $_prefUploadTable = $dialogPreferences->get_widget('_prefUploadTable');
    $_prefInkscapePath = $dialogPreferences->get_widget('_prefInkscapePath');
    $_btnCancel->connect_simple('clicked', 'cancelPreferencesDialog');
    $_btnSave->connect_simple('clicked', 'savePreferencesDialog');
    $_btnRecognizeInkscape->connect_simple('clicked', 'recognizeInkscape');
    $_prefDisplayPreview->connect('toggled', 'setDisplayPreview');
    $_prefUploadEnable->connect_simple('toggled', 'gtToggler', $_prefUploadEnable, $_prefUploadTable);
    $dialogPreferences->get_widget('_prefUploadGetKey')->connect_simple('clicked', 'openURL', 'https://openclipart.org/manage/profile');
    gtIcon($_btnSave, Gtk::STOCK_SAVE);
    gtIcon($_btnCancel, Gtk::STOCK_CANCEL);
    gtIcon($_btnRecognizeInkscape, Gtk::STOCK_FIND);
    gtColor($_noticeLabel, 'fg', $gui['CNoticeBarFG']);
    gtFont($_noticeLabel, $gui['SNoticeBar']);
    gtFont($dialogPreferences->get_widget('_prefUploadGetKeyLBottom'), $gui['XSmallNote']);
    gtFont($dialogPreferences->get_widget('_prefUploadAPIWarn'), $gui['XSmallNote']);
    // Setting states/strings basing on config variable
    if ($config['firstTime']) {
        setPreferencesNoticeBox($i18n->_('prefNoticeFirstTime'));
    }
    // First time, autorun of preferences dialog
    $dialogPreferences->get_widget('_prefDisplayInfobar')->set_active($config['displayInfobar']);
    $dialogPreferences->get_widget('_prefDisplayNavbar')->set_active($config['displayNavbar']);
    $_prefDisplayPreview->set_active($config['displayPreview']);
    $dialogPreferences->get_widget('_prefPreviewAreaBox')->set_sensitive($config['displayPreview']);
    $dialogPreferences->get_widget($radioGroup['toolbarStyle'][$config['toolbarStyle']])->set_active(true);
    $dialogPreferences->get_widget($radioGroup['previewArea'][$config['previewArea']])->set_active(true);
    $_prefUploadEnable->set_active($config['enableUpload']);
    $dialogPreferences->get_widget('_prefUploadNSFW')->set_active($config['NSFWTagToFlag']);
    $_prefUploadTable->set_sensitive($config['enableUpload']);
    gtSetText($dialogPreferences->get_widget('_prefUploadUsername'), $config['uploadUsername']);
    gtSetText($dialogPreferences->get_widget('_prefUploadAPIKey'), $config['uploadAPIKey']);
    $dialogPreferences->get_widget('_prefTempPath')->select_uri($config['tempDirectory']);
    if ($config['inkscapePath']) {
        $_prefInkscapePath->select_uri($config['inkscapePath']);
    } else {
        $_prefInkscapePath->unselect_all();
    }
    // setting language combobox
    $comboIndex = 0;
    foreach ($langList as $code => $name) {
        $comboStr = "{$name} ({$code})";
        $_prefLanguageSelect->append_text($comboStr);
        if ($config['language'] === $code) {
            $_prefLanguageSelect->set_active($comboIndex);
        }
        $comboIndex++;
    }
    // signals that displays infobar notices; they have to be set after widget setup
    $_prefDisplayPreview->connect('toggled', 'setDisplayPreview');
    $dialogPreferences->get_widget('_prefPreviewPage')->connect_simple('toggled', 'setPreferencesNoticeBox', $i18n->_('prefNoticeRefresh'));
    $dialogPreferences->get_widget('_prefPreviewDrawing')->connect_simple('toggled', 'setPreferencesNoticeBox', $i18n->_('prefNoticeDrawingArea') . "\n" . $i18n->_('prefNoticeRefresh'), $gui['CNoticeBarWarnBG']);
    if (detectOS(HK_OS_WINDOWS)) {
        $_prefInkscapePath->connect_simple('file-set', 'checkInkscapePath');
    }
}
Esempio n. 2
0
$glade->get_widget('_btnTipDown')->connect_simple('clicked', 'setTip', 1);
$_btnAbout->connect_simple('clicked', 'showAboutDialog');
$_btnNavRefresh->connect_simple('clicked', 'refreshFile');
foreach ($_btnNav as $type => $btn) {
    $btn->connect_simple('clicked', 'navBarClick', $type);
}
/* Widget customization */
/* See guiOptions.php */
if ($debugMode) {
    $_mainWindow->set_title($i18n->_('debugModeTitle', $_mainWindow->get_title()));
}
gtColor('_infoBox', 'bg', $gui['CNoticeBarBG']);
gtColor($_topLabel, 'fg', $gui['CNoticeBarFG']);
gtFont($_topLabel, $gui['SNoticeBar']);
gtColor($_tipLabel, 'fg', $gui['CNoticeBarFG']);
gtFont($_tipLabel, $gui['XTipOfTheDay']);
/* Setting widgets according to user config */
gtShow($glade->get_widget('_infoBar'), $config['displayInfobar']);
gtShow($glade->get_widget('_navBar'), $config['displayNavbar']);
gtShow($glade->get_widget('_previewArea'), $config['displayPreview']);
$glade->get_widget('_toolbar')->set_toolbar_style($toolbarStyles[$config['toolbarStyle']]);
gtShow($_btnUpload, $config['enableUpload']);
/* Run */
if (!is_dir($config['tempDirectory'])) {
    makeDirHierarchy($config['tempDirectory']);
}
$_previewSpinner->hide();
setTip();
// set initial, random tip of the day
if (isset($argv[1]) && file_exists($argv[1])) {
    readSVG($argv[1]);