static gboolean callback_apply(GtkWidget *widget, gpointer data) { new_settings.gravity = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(wg_gravity)); new_settings.n_blobs = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(wg_n_blobs)); new_settings.blob_size = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(wg_blob_size)); new_settings.blob_falloff = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(wg_blob_falloff)); new_settings.blob_presence = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(wg_blob_presence)); new_settings.border_size = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(wg_border_size)); new_settings.border_falloff = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(wg_border_falloff)); new_settings.border_presence = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(wg_border_presence)); new_settings.multiplication = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(wg_multiplication)); /* the color informations are already in new_settings */ apply_settings(&new_settings); settings_save(); return(TRUE); }
status_t ice1712_set_mix(ice1712 *card, multi_mix_value_info *data) { int i; TRACE_VV(" Asking to set %ld control(s)\n", data->item_count); for (i = 0; i < data->item_count; i++) { multi_mix_value *mmv = &(data->values[i]); TRACE_VV(" Id %#x\n", (unsigned int)mmv->id); switch (mmv->id & ICE1712_MULTI_CONTROL_TYPE_MASK) { case ICE1712_MULTI_CONTROL_TYPE_COMBO: set_combo_cb(card, ICE1712_MULTI_GET_CHANNEL(mmv->id), mmv->u.mux); break; case ICE1712_MULTI_CONTROL_TYPE_VOLUME: set_volume_cb(card, mmv); break; case ICE1712_MULTI_CONTROL_TYPE_OUTPUT: set_output_cb(card, ICE1712_MULTI_GET_CHANNEL(mmv->id), mmv->u.mux); break; default: TRACE_VV(" default 0x%x\n", (unsigned int)mmv->id); break; } } return apply_settings(card); }
void DocumentView::save(const unicode& path) { L_DEBUG("Saving file: " + path.encode()); trim_trailing_newlines(); trim_trailing_whitespace(); Glib::ustring text = buffer()->get_text(); if(file_->get_path() == path.encode()) { //FIXME: Use entity tag arguments to make sure that the file //didn't change since the last time we saved file_->replace_contents(std::string(text.c_str()), "", file_etag_); connect_file_monitor(); } else { auto file = Gio::File::create_for_path(path.encode()); if(!os::path::exists(path)) { file->create_file(); } file->replace_contents(text, "", file_etag_); connect_file_monitor(); } buffer()->set_modified(false); apply_settings(guess_mimetype()); //Make sure we update the settings when we've saved the file window_.rebuild_open_list(); run_linters_and_stuff(); }
void cb_apply_setting(GtkWidget * w, gpointer p) { SettingItem * item = p; if (item->type == ST_IMG_FILE) { gchar * s; if (!(s=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(item->widget)))) return; // for now just ignore setting it to an invalid name if (!strcmp(s,item->fvalue)) { g_free(s); return; } g_free(item->fvalue); item->fvalue=s; check_file(item,s); } write_setting(p,(gpointer) global_theme_file); if (apply) apply_settings(); else { changed=TRUE; } }
/** * Run the daemon. * @param cfgfile: the config file name. * @param cmdline_verbose: verbosity resulting from commandline -v. * These increase verbosity as specified in the config file. * @param debug_mode: if set, do not daemonize. * @param log_default_identity: Default identity to report in logs */ static void run_daemon(const char* cfgfile, int cmdline_verbose, int debug_mode, const char* log_default_identity) { struct config_file* cfg = NULL; struct daemon* daemon = NULL; int done_setup = 0; if(!(daemon = daemon_init())) fatal_exit("alloc failure"); while(!daemon->need_to_exit) { if(done_setup) verbose(VERB_OPS, "Restart of %s.", PACKAGE_STRING); else verbose(VERB_OPS, "Start of %s.", PACKAGE_STRING); /* config stuff */ if(!(cfg = config_create())) fatal_exit("Could not alloc config defaults"); if(!config_read(cfg, cfgfile, daemon->chroot)) { if(errno != ENOENT) fatal_exit("Could not read config file: %s", cfgfile); log_warn("Continuing with default config settings"); } apply_settings(daemon, cfg, cmdline_verbose, debug_mode, log_default_identity); if(!done_setup) config_lookup_uid(cfg); /* prepare */ if(!daemon_open_shared_ports(daemon)) fatal_exit("could not open ports"); if(!done_setup) { perform_setup(daemon, cfg, debug_mode, &cfgfile); done_setup = 1; } else { /* reopen log after HUP to facilitate log rotation */ if(!cfg->use_syslog) log_init(cfg->logfile, 0, cfg->chrootdir); } /* work */ daemon_fork(daemon); /* clean up for restart */ verbose(VERB_ALGO, "cleanup."); daemon_cleanup(daemon); config_delete(cfg); } verbose(VERB_ALGO, "Exit cleanup."); /* this unlink may not work if the pidfile is located outside * of the chroot/workdir or we no longer have permissions */ if(daemon->pidfile) { int fd; /* truncate pidfile */ fd = open(daemon->pidfile, O_WRONLY | O_TRUNC, 0644); if(fd != -1) close(fd); /* delete pidfile */ unlink(daemon->pidfile); } daemon_delete(daemon); }
static gboolean cb_apply_setting_real(gpointer p) { SettingItem * item = p; cb_apply_setting_timer_tag = 0; if (item->type == ST_IMG_FILE) { gchar * s; /* for now just ignore setting it to an invalid name */ if (!(s=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(item->widget)))) return FALSE; if (g_strcmp0(s,item->fvalue) == 0) { g_free(s); return FALSE; } g_free(item->fvalue); item->fvalue=s; check_file(item,s); } write_setting(p,(gpointer) global_theme_file); if (apply) apply_settings(); else { changed=TRUE; } return FALSE; }
void CLI::read_settings() { int user_option = -1; while (user_option != QUIT) { show_settings(); user_option = get_user_option(); apply_settings(user_option); } }
void cb_clear_file(GtkWidget * button, gpointer p) { SettingItem * item = p; check_file(item,""); item->fvalue=""; gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(item->widget)); write_setting(p,global_theme_file); if (apply) apply_settings(); }
static void save_settings(void) { apply_settings(); // Save settings nsoption_write( (const char*)&options ); nsoption_read( (const char*)&options ); close_settings(); form_alert(1, "[1][Some options require an netsurf restart!][OK]"); deskmenu_update(); }
window::window(QWidget *parent) : QDialog(parent), ui(new Ui::window) { ui->setupUi(this); friends_table = new table_model(this); ui->tableView->setModel(friends_table); ui->tableView->verticalHeader()->hide(); ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows); connect(ui->add, SIGNAL(clicked()), this, SLOT(add_row())); connect(ui->remove, SIGNAL(clicked()), this, SLOT(remove_rows())); connect(ui->close, SIGNAL(clicked()), this, SLOT(apply_settings())); manager = new QNetworkAccessManager(this); connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(readyRead(QNetworkReply*))); // define tray icon QAction * quit_action = new QAction(tr("&Quit"), this); connect(quit_action, SIGNAL(triggered()), qApp, SLOT(quit())); QAction * settings_action = new QAction(tr("&Settings"), this); connect(settings_action, SIGNAL(triggered()), this, SLOT(show())); QMenu * tray_menu = new QMenu(this); tray_menu->addAction(settings_action); tray_menu->addSeparator(); tray_menu->addAction(quit_action); tray_icon = new QSystemTrayIcon(this); tray_icon->setContextMenu(tray_menu); connect(tray_icon, SIGNAL(messageClicked()), this, SLOT(messageClicked())); connect(tray_icon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); QIcon icon(":/images/teeworlds_1.png"); tray_icon->setIcon(icon); setWindowIcon(icon); tray_icon->setToolTip("Teeworlds Notifier"); tray_icon->show(); timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(mainloop())); //timer->start(update_interval * 1000); need_correction = 2; mainloop(); }
char *v4l_guess(char *str, int *fd) { char *dev = NULL, *settings = NULL, *atparms = NULL; parse_str(str, &dev, &settings, &atparms); init_freqs(); v4l1_cap = -1; v4l2_cap = -1; *fd = -1; if (dev == NULL) { rfbLog("v4l_guess: could not find device in: %s\n", str); return NULL; } if (settings) { apply_settings(dev, settings, fd); } if (atparms) { /* use user's parameters. */ char *t = (char *) malloc(5+strlen(dev)+1+strlen(atparms)+1); sprintf(t, "snap:%s@%s", dev, atparms); return t; } /* try to query the device for parameters. */ atparms = guess_via_v4l(dev, fd); if (atparms == NULL) { /* try again with v4l-info(1) */ atparms = guess_via_v4l_info(dev, fd); } if (atparms == NULL) { /* bad news */ if (*fd >= 0) { close(*fd); } *fd = -1; return NULL; } else { char *t = (char *) malloc(5+strlen(dev)+1+strlen(atparms)+1); sprintf(t, "snap:%s@%s", dev, atparms); return t; } }
void PreferencesThread::handle_close_event(int result) { thread_running = 0; if(!result) { apply_settings(); mwindow->save_defaults(); } window = 0; delete preferences; edl->Garbage::remove_user(); preferences = 0; edl = 0; mwindow->defaults->update("DEFAULTPREF", current_dialog); }
void PreferencesThread::run() { int need_new_indexes; preferences = new Preferences; edl = new EDL; edl->create_objects(); current_dialog = mwindow->defaults->get("DEFAULTPREF", 0); preferences->copy_from(mwindow->preferences); edl->copy_session(mwindow->edl); redraw_indexes = 0; redraw_meters = 0; redraw_times = 0; redraw_overlays = 0; close_assets = 0; reload_plugins = 0; need_new_indexes = 0; rerender = 0; int x = mwindow->gui->get_root_w(0, 1) / 2 - WIDTH / 2; int y = mwindow->gui->get_root_h(1) / 2 - HEIGHT / 2; window_lock->lock("PreferencesThread::run 1"); window = new PreferencesWindow(mwindow, this, x, y); window->create_objects(); window_lock->unlock(); thread_running = 1; int result = window->run_window(); thread_running = 0; if(!result) { apply_settings(); mwindow->save_defaults(); } window_lock->lock("PreferencesThread::run 2"); delete window; window = 0; window_lock->unlock(); delete preferences; delete edl; mwindow->defaults->update("DEFAULTPREF", current_dialog); }
void DocumentView::run_linters_and_stuff(bool force) { L_DEBUG("DocumentView::run_linters_and_stuff"); if(!force && window().current_buffer().get() != this) { //Only run linters on the active document L_DEBUG("Document is not active, not running"); return; } L_DEBUG("Detecting language"); apply_language_to_buffer(guess_language_from_file(file_)); L_DEBUG("Applying settings"); apply_settings(guess_mimetype()); //Make sure we update the settings when we've reloaded the file //Check for coverage stats auto language = buffer()->get_language(); unicode name = (language) ? unicode(language->get_name()) : ""; if(name == "Python") { if(!coverage_) { std::cout << "COVERAGE: Creating coverage" << std::endl; coverage_ = std::make_shared<coverage::PythonCoverage>(); //Connect to the coverage updated signal and re-run this function if that happens coverage_->signal_coverage_updated().connect(std::bind(&DocumentView::run_linters_and_stuff, this, false)); } coverage_->apply_to_document(this); linter_ = std::make_shared<linter::PythonLinter>(); linter_->apply_to_document(this); } else if(name == "JavaScript") { linter_ = std::make_shared<linter::JavascriptLinter>(); linter_->apply_to_document(this); } else { if(coverage_) { coverage_->clear_document(this); coverage_.reset(); } if(linter_) { linter_->clear_document(this); linter_.reset(); } } }
status_t ice1712_set_mix(ice1712 *card, multi_mix_value_info *data) { int i; TRACE(" Asking to set %ld control(s)\n", data->item_count); for (i = 0; i < data->item_count; i++) { multi_mix_value *mmv = &(data->values[i]); switch (mmv->id & ICE1712_MULTI_CONTROL_MASK) { case ICE1712_MULTI_CONTROL_VOLUME_PB: card->settings.playback[mmv->id & ICE1712_MULTI_CONTROL_CHANNEL_MASK].volume = mmv->u.gain; TRACE(" ICE1712_MULTI_CONTROL_VOLUME_PB 0x%x : %f\n", (unsigned int)mmv->id, mmv->u.gain); break; case ICE1712_MULTI_CONTROL_VOLUME_REC: card->settings.record[mmv->id & ICE1712_MULTI_CONTROL_CHANNEL_MASK].volume = mmv->u.gain; TRACE(" ICE1712_MULTI_CONTROL_VOLUME_REC 0x%x : %f\n", (unsigned int)mmv->id, mmv->u.gain); break; case ICE1712_MULTI_CONTROL_MUTE | ICE1712_MULTI_CONTROL_VOLUME_PB: card->settings.playback[mmv->id & ICE1712_MULTI_CONTROL_CHANNEL_MASK].mute = mmv->u.enable; card->settings.playback[(mmv->id & ICE1712_MULTI_CONTROL_CHANNEL_MASK) + 1].mute = mmv->u.enable; TRACE(" ICE1712_MULTI_CONTROL_MUTE_PB 0x%x : %d\n", (unsigned int)mmv->id, mmv->u.enable); break; case ICE1712_MULTI_CONTROL_MUTE | ICE1712_MULTI_CONTROL_VOLUME_REC: card->settings.record[mmv->id & ICE1712_MULTI_CONTROL_CHANNEL_MASK].mute = mmv->u.enable; card->settings.record[(mmv->id & ICE1712_MULTI_CONTROL_CHANNEL_MASK) + 1].mute = mmv->u.enable; TRACE(" ICE1712_MULTI_CONTROL_MUTE_REC 0x%x : %d\n", (unsigned int)mmv->id, mmv->u.enable); break; case ICE1712_MULTI_CONTROL_MUX: TRACE(" ICE1712_MULTI_CONTROL_MUX 0x%x : 0x%x\n", (unsigned int)mmv->id, (unsigned int)mmv->u.mux); break; default: TRACE(" default 0x%x\n", (unsigned int)mmv->id); break; } } return apply_settings(card); }
void DocumentView::build_widgets() { scrolled_window_.add(view_); view_.set_buffer(buffer_); view_.signal_populate_popup().connect(sigc::mem_fun(this, &DocumentView::populate_popup)); auto manager = Gsv::StyleSchemeManager::get_default(); view_.get_source_buffer()->set_style_scheme(manager->get_scheme("delimit")); auto provider = Gsv::CompletionWords::create("", Glib::RefPtr<Gdk::Pixbuf>()); provider->register_provider(buffer_); provider->property_priority().set_value(1); view_.get_completion()->add_provider(provider); view_.get_completion()->signal_show().connect([&]() { completion_visible_ = true; }); view_.get_completion()->signal_hide().connect([&]() { completion_visible_ = false; }); auto coverage_attrs = Gsv::MarkAttributes::create(); Gdk::RGBA coverage_colour; coverage_colour.set_rgba(1.0, 0.5, 0, 0.12); coverage_attrs->set_background(coverage_colour); view_.set_mark_attributes("coverage", coverage_attrs, 0); auto linter_attrs = Gsv::MarkAttributes::create(); linter_attrs->set_icon_name("dialog-error"); g_signal_connect(linter_attrs->gobj(), "query-tooltip-markup", G_CALLBACK(get_tooltip), view_.gobj()); view_.set_mark_attributes("linter", linter_attrs, 10); auto breakpoint = Gsv::MarkAttributes::create(); breakpoint->set_icon_name("stop"); view_.set_mark_attributes("breakpoint", breakpoint, 11); view_.add_events(Gdk::BUTTON_PRESS_MASK); view_.signal_button_press_event().connect([&](GdkEventButton* evt) -> bool { if(!buffer_->get_language() || buffer_->get_language()->get_name() != "Python") { return false; } if(evt->type == GDK_2BUTTON_PRESS && evt->window == view_.get_window(Gtk::TEXT_WINDOW_LEFT)->gobj()) { //The user clicked within the left gutter if(evt->button == 1) { //Left click int x_buf, y_buf; view_.window_to_buffer_coords( Gtk::TEXT_WINDOW_LEFT, int(evt->x), int(evt->y), x_buf, y_buf ); //Line bounds Gtk::TextBuffer::iterator iter; int line_top; view_.get_line_at_y(iter, y_buf, line_top); auto mark_list = buffer_->get_source_marks_at_iter(iter, "breakpoint"); if(!mark_list.empty()) { for(auto& mark: mark_list) { buffer_->delete_mark(mark); } auto end_iter = iter; end_iter.forward_line(); unicode line = buffer_->get_slice(iter, end_iter).c_str(); if(line.contains("import ipdb; ipdb.set_trace()")) { buffer_->erase(iter, end_iter); } } else { buffer_->create_source_mark("breakpoint", iter); auto end_iter = iter; end_iter.forward_line(); unicode line_text = buffer_->get_slice(iter, end_iter).c_str(); uint32_t i = 0; for(; i < line_text.length(); ++i) { if(line_text[i] != ' ' && line_text[i] != '\t') { break; } } auto indentation = line_text.slice(nullptr, i); auto replacement_text = _u("{0}import ipdb; ipdb.set_trace();\n").format(indentation); buffer_->insert(iter, replacement_text.encode()); } } } return false; }); apply_settings("text/plain"); scrolled_window_.show_all(); }
/** * @brief Slot called when the quest execution begins. */ void Console::quest_running() { // Apply settings to the running quest as Lua commands, // for quests that don't read the settings.dat file. apply_settings(); }