void Widget_Preview::on_zoom_entry_activated() { Gtk::Entry* entry = zoom_preview.get_entry(); String str(entry->get_text()); string digi = "0123456789"; size_t first = str.find_first_of(digi); if (first == string::npos) { entry->set_text(_("Fit")); //release the focus to enable accelerator keys preview_window.grab_focus(); return ; } size_t last = str.find_first_not_of(digi); if (last == string::npos) { last = str.find_last_of(digi) + 1; } if (first > last) { entry->set_text (_("Fit")); } else entry->set_text(str.substr(first, last - first) + "%"); //release the focus to enable accelerator keys preview_window.grab_focus(); }
void PreferencesDialogImpl::defaultButtonCB() { Config::defaultConfig(); m_editorEntry->set_text(g_configMap[Config::EDITOR[0]]); m_ctagsEntry->set_text(g_configMap[Config::CTAGS[0]]); }
void MainWindow::on_button_enter() { std::thread( [this](int dummy) { std::string query = m_entry.get_text(); m_entry.set_sensitive(false); m_entry.set_text("計算中です..."); CrTrimString(query); auto result = ChJustDoIt(query); ChFixResultForDisplay(result); std::string contents("にゅうりょく:"); contents += query; contents += '\n'; contents += result; contents += '\n'; add_output(contents); if (result.find("しゅうりょうします") != std::string::npos) { m_entry.set_text("終了中です..."); hide(); } m_entry.set_text(""); m_entry.set_sensitive(true); set_focus(m_entry); }, 0 ).detach(); }
void GscPreferencesWindow::update_device_widgets(const std::string& device, const std::string& params) { Gtk::Entry* entry = 0; if ((entry = this->lookup_widget<Gtk::Entry*>("device_options_device_entry"))) entry->set_text(device); if ((entry = this->lookup_widget<Gtk::Entry*>("device_options_parameter_entry"))) entry->set_text(params); }
void GscPreferencesWindow::import_config() { // Clear and fill the entries. Gtk::CheckButton* check = 0; Gtk::Entry* entry = 0; // ------- General tab bool scan_on_startup; if ( prefs_config_get("gui/scan_on_startup", scan_on_startup) && (check = this->lookup_widget<Gtk::CheckButton*>("scan_on_startup_check")) ) check->set_active(scan_on_startup); bool show_smart_capable_only; if ( prefs_config_get("gui/show_smart_capable_only", show_smart_capable_only) && (check = this->lookup_widget<Gtk::CheckButton*>("show_smart_capable_only_check")) ) check->set_active(show_smart_capable_only); bool win32_search_smartctl_in_smartmontools; if ( prefs_config_get("system/win32_search_smartctl_in_smartmontools", win32_search_smartctl_in_smartmontools) && (check = this->lookup_widget<Gtk::CheckButton*>("search_in_smartmontools_first_check")) ) check->set_active(win32_search_smartctl_in_smartmontools); std::string smartctl_binary; if ( prefs_config_get("system/smartctl_binary", smartctl_binary) && (entry = this->lookup_widget<Gtk::Entry*>("smartctl_binary_entry")) ) entry->set_text(smartctl_binary); std::string smartctl_options; if ( prefs_config_get("system/smartctl_options", smartctl_options) && (entry = this->lookup_widget<Gtk::Entry*>("smartctl_options_entry")) ) entry->set_text(smartctl_options); // ------- Drives tab std::string device_blacklist_patterns; if ( prefs_config_get("system/device_blacklist_patterns", device_blacklist_patterns) && (entry = this->lookup_widget<Gtk::Entry*>("device_blacklist_patterns_entry")) ) entry->set_text(device_blacklist_patterns); std::string devmap_str; if ( prefs_config_get("system/smartctl_device_options", devmap_str) ) { device_option_map_t devmap = app_unserialize_device_option_map(devmap_str); device_options_treeview->set_device_map(devmap); } }
//-------------------------------------------------------------------------------- void DbMySQLTableEditorFKPage::cell_editing_started(GtkCellRenderer* cr, GtkCellEditable* ce, gchar* path, gpointer udata) { DbMySQLTableEditorFKPage* self = reinterpret_cast<DbMySQLTableEditorFKPage*>(udata); bec::NodeId node(path); if ( node.is_valid() ) self->_fk_node = node; if ( GTK_IS_ENTRY(ce) ) // Fill in name of the foreign key column { ::bec::FKConstraintListBE *fk_be = self->_be->get_fks(); Gtk::Entry* entry = Glib::wrap(GTK_ENTRY(ce)); std::string name; if (node.back() == fk_be->count()-1) fk_be->set_field(node, bec::FKConstraintListBE::Name, 1); fk_be->get_field(node, bec::FKConstraintListBE::Name, name); entry->set_text(name); } // clean up edit_done signal/slotl if ( self->_ce && self->_edit_conn ) { g_signal_handler_disconnect (self->_ce, self->_edit_conn); self->_ce = 0; self->_edit_conn = 0; } if (GTK_IS_CELL_EDITABLE(ce)) { self->_ce = ce; self->_edit_conn = g_signal_connect(ce, "editing-done", GCallback(&DbMySQLTableEditorFKPage::cell_editing_done), udata); } }
void Settings::set_to_gui (Builder &builder, int i) { const char *glade_name = settings[i].glade_name; if (!glade_name) return; switch (settings[i].type) { case T_BOOL: { Gtk::CheckButton *check = NULL; builder->get_widget (glade_name, check); if (!check) std::cerr << "Missing boolean config item " << glade_name << "\n"; else check->set_active (*PTR_BOOL(this, i)); break; } case T_INT: case T_FLOAT: { Gtk::Widget *w = NULL; builder->get_widget (glade_name, w); if (!w) { std::cerr << "Missing user interface item " << glade_name << "\n"; break; } Gtk::SpinButton *spin = dynamic_cast<Gtk::SpinButton *>(w); if (spin) { if (settings[i].type == T_INT) spin->set_value (*PTR_INT(this, i)); else spin->set_value (*PTR_FLOAT(this, i)); break; } Gtk::Range *range = dynamic_cast<Gtk::Range *>(w); if (range) { if (settings[i].type == T_INT) range->set_value (*PTR_INT(this, i)); else range->set_value (*PTR_FLOAT(this, i)); } break; } case T_STRING: { Gtk::Entry *e = NULL; builder->get_widget (glade_name, e); if (!e) { std::cerr << "Missing user interface item " << glade_name << "\n"; break; } e->set_text(*PTR_STRING(this, i)); break; } case T_COLOUR_MEMBER: break; // Ignore, Colour members are special default: std::cerr << "corrupt setting type\n"; break; } }
static void sp_attribute_table_object_modified ( SPObject */*object*/, guint flags, SPAttributeTable *spat ) { if (flags && SP_OBJECT_MODIFIED_FLAG) { std::vector<Glib::ustring> attributes = spat->get_attributes(); std::vector<Gtk::Entry *> entries = spat->get_entries(); Glib::ustring text=""; for (guint i = 0; i < (attributes.size()); i++) { Gtk::Entry* e = entries[i]; const gchar *val = spat->_object->getRepr()->attribute(attributes[i].c_str()); text = e->get_text (); if (val || !text.empty()) { if (text != val) { /* We are different */ spat->blocked = true; e->set_text (val ? val : (const gchar *) ""); spat->blocked = false; } } } } } // end of sp_attribute_table_object_modified()
void dialog::operate4(Image imag,std::string filename) { set_default_size(300, 50); set_border_width(10); set_position(Gtk::WIN_POS_CENTER); set_resizable(false); Gtk::Box *vbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL, 0)); add(*vbox); Gtk::Grid *grid = Gtk::manage(new Gtk::Grid); vbox->add(*grid); Gtk::Label *label = Gtk::manage(new Gtk::Label("File Name :")); grid->attach(*label,0,0,1,1); Gtk::Entry *bvalue = Gtk::manage(new Gtk::Entry()); grid->attach(*bvalue, 1, 0, 1, 1); Gtk::Label *label2 = Gtk::manage(new Gtk::Label(".bmp")); grid->attach(*label2,2,0,1,1); set_title("Save As"); bvalue->set_text("Untitled"); bvalue->set_max_length(50); Gtk::Button *bok = Gtk::manage(new Gtk::Button("OK")); bok->signal_clicked().connect(sigc::bind<Gtk::Entry*>(sigc::mem_fun(*this, &dialog::on_bok4_click), bvalue,imag,filename)); grid->attach(*bok, 2, 2, 1, 1); show_all_children(); }
//-------------------------------------------------------------------------------- void DbMySQLTableEditorIndexPage::cell_editing_done(GtkCellEditable *ce) { if (_editing_done_id != 0 && _editable_cell != 0) { g_signal_handler_disconnect(_editable_cell, _editing_done_id); _editing_done_id = 0; _editable_cell = 0; } // If it's Gtk::Entry, we try to find out if maybe user leave edit field empty, // if so we revert it to the last known value or to the default one. if (GTK_IS_ENTRY(ce)) { GtkEntry *entry_widget = GTK_ENTRY(ce); if (entry_widget) { Gtk::Entry *entry = Glib::wrap(entry_widget); if (entry && entry->get_text_length() == 0) { Gtk::TreeModel::Path path; Gtk::TreeView::Column *column(0); _indexes_tv->get_cursor(path, column); bec::NodeId node(path.to_string()); if (node.is_valid()) { std::string name = _user_index_name; if (name.empty()) name = strfmt("index%i", path[0] + 1); _be->get_indexes()->set_field(node, MySQLTableIndexListBE::Name, name); entry->set_text(name); } } } } }
/*! \brief This function is designed to be used in a Gtk::Entry's signal_changed() callback. It enforces that the text is formatted in the style of a numeric value. It allows the first character to be a minus or plus sign, there to be a sequence of digits, possibly split by one decimal point. An example use is \code entry.signal_changed().connect(sigc::bind<Gtk::Entry&>(&magnet::Gtk::forceNumericEntry, entry)); \endcode */ inline void forceNumericEntry(::Gtk::Entry& textfield) { std::string value = textfield.get_text(); bool hasPoint = false; bool hasExponent = false; std::string::iterator iPtr = value.begin(); if ((*iPtr == '-') || (*iPtr == '+')) ++iPtr; while (iPtr != value.end()) if (std::isdigit(*iPtr)) ++iPtr; else if ((*iPtr == '.') && (!hasPoint)) { ++iPtr; hasPoint = true; } else if ((*iPtr == 'e') && (!hasExponent) && (iPtr != value.begin()) && std::isdigit(*(iPtr - 1))) { //If the last value was a digit we can have a single e //argument, but don't allow decimal exponents hasExponent=true; hasPoint = true; ++iPtr; //Eat the sign of the exponent if ((*iPtr == '-') || (*iPtr == '+')) ++iPtr; } else iPtr = value.erase(iPtr); if (value[0] == '.') value.erase(value.begin()); textfield.set_text(value); }
virtual void do_refresh_form_data() { Gtk::Entry *entry; xml()->get_widget("name_entry", entry); Gtk::TextView *tview; xml()->get_widget("text_view", tview); Gtk::ComboBox *combo; xml()->get_widget("collation_combo", combo); Gtk::Button *btn; xml()->get_widget("refactor_btn", btn); if (_be) { set_selected_combo_item(combo, _be->get_schema_option_by_name("CHARACTER SET - COLLATE")); _old_name = _be->get_name(); entry->set_text(_old_name); tview->get_buffer()->set_text(_be->get_comment()); bool is_editing_live_obj= is_editing_live_object(); tview->set_sensitive(!is_editing_live_obj); Gtk::Label *tlabel; xml()->get_widget("label5", tlabel); tlabel->set_sensitive(!is_editing_live_obj); btn->set_sensitive(_be->refactor_possible()); } }
std::string DialogBoxFactory::showDomainIDataEditDialog(int Id, std::string DataName, std::string Val) { Gtk::Dialog Dialog(_("Edit Inputdata"), true, false); Gtk::Entry Entry; Entry.set_text(Val); Gtk::Label Label(Glib::ustring::compose(_("%1 for ID %2"), DataName,Id)); Dialog.get_vbox()->pack_start(Label); Dialog.get_vbox()->pack_start(Entry); Dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); Dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); Dialog.set_default_response(Gtk::RESPONSE_OK); Dialog.show_all_children(); int Res = Dialog.run(); if (Res == Gtk::RESPONSE_CANCEL || Res == Gtk::RESPONSE_DELETE_EVENT) return Val; std::string NewVal = Entry.get_text(); if (NewVal == "" || NewVal == " ") NewVal = "0"; return NewVal; }
virtual void do_refresh_form_data() { Gtk::Entry *entry; int w, h; _be.get_size(w, h); _xml->get_widget("width_entry", entry); entry->set_text(strfmt("%i", w)); _xml->get_widget("height_entry", entry); entry->set_text(strfmt("%i", h)); Gtk::CheckButton *check; _xml->get_widget("aspect_check", check); check->set_active(_be.get_keep_aspect_ratio()); Glib::RefPtr<Gdk::Pixbuf> pixbuf(Gdk::Pixbuf::create_from_file(_be.get_attached_image_path())); if (pixbuf) _image->set(pixbuf); else g_message("ImageEditorFE: can not set image from %s[%s]", _be.get_filename().c_str(), _be.get_attached_image_path().c_str()); }
void stock::on_eArticleID_changed(){ Gtk::Entry* arID ; window->get_widget("eArticleID",arID); int newID = String2Int(arID->get_text()) ; if(newID > 0){ singleArticle->load(newID); Gtk::Entry* arDes ; window->get_widget("eArticleNumber",arDes); arDes->set_text(singleArticle->firstRecord.row_string["number"] + " " + singleArticle->firstRecord.row_string["designation"]); } }
void SPAttributeTable::set_object(SPObject *object, std::vector<Glib::ustring> &labels, std::vector<Glib::ustring> &attributes, GtkWidget* parent) { g_return_if_fail (!object || SP_IS_OBJECT (object)); g_return_if_fail (!object || !labels.empty() || !attributes.empty()); g_return_if_fail (labels.size() == attributes.size()); clear(); _object = object; if (object) { blocked = true; // Set up object modified_connection = object->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_attribute_table_object_modified), this)); release_connection = object->connectRelease (sigc::bind<1>(sigc::ptr_fun(&sp_attribute_table_object_release), this)); // Create table table = new Gtk::Table (attributes.size(), 2, false); if (!(parent == NULL)) { gtk_container_add (GTK_CONTAINER (parent),(GtkWidget*)table->gobj()); } // Fill rows _attributes = attributes; for (guint i = 0; i < (attributes.size()); i++) { Gtk::Label *ll = new Gtk::Label (_(labels[i].c_str())); ll->show(); ll->set_alignment (1.0, 0.5); table->attach (*ll, 0, 1, i, i + 1, Gtk::FILL, (Gtk::EXPAND | Gtk::FILL), XPAD, YPAD ); Gtk::Entry *ee = new Gtk::Entry(); ee->show(); const gchar *val = object->getRepr()->attribute(attributes[i].c_str()); ee->set_text (val ? val : (const gchar *) ""); table->attach (*ee, 1, 2, i, i + 1, (Gtk::EXPAND | Gtk::FILL), (Gtk::EXPAND | Gtk::FILL), XPAD, YPAD ); _entries.push_back(ee); g_signal_connect ( ee->gobj(), "changed", G_CALLBACK (sp_attribute_table_entry_changed), this ); } /* Show table */ table->show (); blocked = false; } }
virtual void do_refresh_form_data() { Gtk::Entry *entry; _xml->get_widget("name_entry", entry); Gtk::TextView *tview; _xml->get_widget("text_view", tview); entry->set_text(_be.get_name()); tview->get_buffer()->set_text(_be.get_text()); }
void LastFmPlugin::showSettingsDialog(Gejengel::Settings& settings) { Gtk::Dialog dlg(string("Last.fm ") + _("settings"), true); Gtk::Table layout(2, 2, false); Gtk::Entry userEntry; userEntry.set_text(settings.get("LastFmUser")); Gtk::Entry passEntry; passEntry.set_visibility(false); passEntry.set_text(settings.get("LastFmPass")); layout.attach(*Gtk::manage(new Gtk::Label(_("Username: "******"Password: "******"LastFmUser", user); if (pass != settings.get("LastFmPass")) { pass = LastFmClient::generatePasswordHash(pass); settings.set("LastFmPass", pass); } m_pScrobbler.reset(new LastFmScrobbler(userEntry.get_text(), pass, true, true)); }
void GscPreferencesWindow::on_smartctl_binary_browse_button_clicked() { std::string default_file; Gtk::Entry* entry = this->lookup_widget<Gtk::Entry*>("smartctl_binary_entry"); if (!entry) return; Gtk::FileChooserDialog dialog(*this, "Choose Smartctl Binary...", Gtk::FILE_CHOOSER_ACTION_OPEN); // Add response buttons the the dialog dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT); // Note: This works on absolute paths only (otherwise it's gtk warning). hz::FsPath p(entry->get_text()); if (p.is_absolute()) dialog.set_filename(p.str()); // change to its dir and select it if exists. // Show the dialog and wait for a user response int result = dialog.run(); // the main cycle blocks here // Handle the response switch (result) { case Gtk::RESPONSE_ACCEPT: { entry->set_text(std::string(dialog.get_filename())); break; } case Gtk::RESPONSE_CANCEL: case Gtk::RESPONSE_DELETE_EVENT: // nothing, the dialog is closed already break; default: debug_out_error("app", DBG_FUNC_MSG << "Unknown dialog response code: " << result << ".\n"); break; } }
void AsistenteJerarquia::inicializarAsistente() { if (this->vjerarquia->getEntidadPadre() != NULL){ Gtk::Entry *entryNombre = 0; Gtk::RadioButton* radio =NULL; if (this->vjerarquia->getJerarquia()->getCobertura() == TIPO_COBERTURA_PARCIAL){ this->m_builder->get_widget("radioParcial", radio); radio->set_active(true); }else{ this->m_builder->get_widget("radioTotal", radio); radio->set_active(true); } if (this->vjerarquia->getJerarquia()->getInterseccion() == TIPO_INTERSECCION_EXCLUSIVA){ this->m_builder->get_widget("radioExclusiva", radio); radio->set_active(true); }else{ this->m_builder->get_widget("radioSuperpuesta", radio); radio->set_active(true); } this->m_builder->get_widget("entryNombre", entryNombre); entryNombre->set_text(this->vjerarquia->getNombre()); this->inicializarListaEntidades(); } }
void ProjectSettingsDialog :: setText(Gtk::Entry& control, const char* value) { if (!_ELENA_::emptystr(value)) { control.set_text(value); } }
/*! Constructor * \param[in] el the configuration element to display * \param[in] differ shall the changes be applied later using apply_changes()? */ ConfigElement::ConfigElement(crn::ConfigElement &el, bool differ): value(el.GetValue()), tmpvalue(el.GetValue()) { if (!value) throw crn::ExceptionUninitialized(_("The element was not initialized.")); if (differ) tmpvalue = crn::Clone(*value); if (std::dynamic_pointer_cast<crn::Int>(tmpvalue)) typ = U"Int"; else if (std::dynamic_pointer_cast<crn::Real>(tmpvalue)) typ = U"Real"; else if (std::dynamic_pointer_cast<crn::Prop3>(tmpvalue)) typ = U"Prop3"; else if (std::dynamic_pointer_cast<crn::String>(tmpvalue)) typ = U"String"; else if (std::dynamic_pointer_cast<crn::StringUTF8>(tmpvalue)) typ = U"StringUTF8"; else if (std::dynamic_pointer_cast<crn::Path>(tmpvalue)) typ = U"Path"; Gtk::Label *lab = Gtk::manage(new Gtk::Label(el.GetName().CStr())); lab->show(); pack_start(*lab, false, true, 2); if (typ == U"Prop3") { Prop3 *p = Gtk::manage(new Prop3(Gtk::ICON_SIZE_BUTTON, el.GetValue<crn::Prop3>())); p->signal_value_changed().connect(sigc::mem_fun(this, &ConfigElement::on_p3_changed)); p->show(); pack_start(*p, true, true, 2); } else if (!el.GetAllowedValues().IsEmpty()) { // any Int, Real, String, StringUTF8 or Path Gtk::ComboBoxText *cb = Gtk::manage(new Gtk::ComboBoxText); const std::vector<crn::StringUTF8> values(el.GetAllowedValues<crn::StringUTF8>()); for (const crn::StringUTF8 &val : values) #ifdef CRN_USING_GTKMM3 cb->append(val.CStr()); #else /* CRN_USING_GTKMM3 */ cb->append_text(val.CStr()); #endif /* CRN_USING_GTKMM3 */ cb->set_active_text(el.GetValue<crn::StringUTF8>().CStr()); cb->signal_changed().connect(sigc::bind(sigc::mem_fun(this, &ConfigElement::on_combo_changed), cb)); cb->show(); pack_start(*cb, true, true, 2); } else if (typ == U"Int") { if (el.HasMinValue() && el.HasMaxValue()) { // has finite range, use a slider #ifdef CRN_USING_GTKMM3 auto *s = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL)); s->set_range(el.GetMinValue<int>(), el.GetMaxValue<int>() + 1); s->set_increments(1, 1); #else Gtk::HScale *s = Gtk::manage(new Gtk::HScale(el.GetMinValue<int>(), el.GetMaxValue<int>() + 1, 1)); #endif s->set_value(el.GetValue<int>()); s->signal_value_changed().connect(sigc::bind(sigc::mem_fun(this, &ConfigElement::on_range_changed), s)); s->show(); pack_start(*s, true, true, 2); } else { // has at least one infinite (maxed) bound, use a spin button Gtk::SpinButton *s = Gtk::manage(new Gtk::SpinButton); int m = std::numeric_limits<int>::min(), M = std::numeric_limits<int>::max(); if (el.HasMinValue()) m = el.GetMinValue<int>(); if (el.HasMaxValue()) M = el.GetMaxValue<int>(); s->set_range(m, M); s->set_increments(1, 10); s->set_value(el.GetValue<int>()); s->signal_value_changed().connect(sigc::bind(sigc::mem_fun(this, &ConfigElement::on_spin_changed), s)); s->show(); pack_start(*s, true, true, 2); } } else if (typ == U"Real") { if (el.HasMinValue() && el.HasMaxValue()) { // has finite range, use a slider #ifdef CRN_USING_GTKMM3 auto *s = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL)); s->set_range(el.GetMinValue<double>(), el.GetMaxValue<double>() + 0.01); s->set_increments(0.01, 0.01); #else Gtk::HScale *s = Gtk::manage(new Gtk::HScale(el.GetMinValue<double>(), el.GetMaxValue<double>() + 0.01, 0.01)); #endif s->set_digits(2); s->set_value(el.GetValue<double>()); s->signal_value_changed().connect(sigc::bind(sigc::mem_fun(this, &ConfigElement::on_range_changed), s)); s->show(); pack_start(*s, true, true, 2); } else { // has at least one infinite (maxed) bound, use a spin button Gtk::SpinButton *s = Gtk::manage(new Gtk::SpinButton(0, 2)); double m = -std::numeric_limits<double>::max(), M = std::numeric_limits<double>::max(); if (el.HasMinValue()) m = el.GetMinValue<double>(); if (el.HasMaxValue()) M = el.GetMaxValue<double>(); s->set_range(m, M); s->set_increments(0.01, 1); s->set_value(el.GetValue<double>()); s->signal_value_changed().connect(sigc::bind(sigc::mem_fun(this, &ConfigElement::on_spin_changed), s)); s->show(); pack_start(*s, true, true, 2); } } else // string types { Gtk::Entry *e = Gtk::manage(new Gtk::Entry); e->set_text(el.GetValue<crn::StringUTF8>().CStr()); e->signal_changed().connect(sigc::bind(sigc::mem_fun(this, &ConfigElement::on_entry_changed), e)); e->show(); pack_start(*e, true, true, 2); } lab = Gtk::manage(new Gtk::Label("?")); lab->show(); lab->set_tooltip_text(el.GetDescription().CStr()); pack_start(*lab, false, true, 2); }
void set_family(String s) { return family_entry.set_text(s); }
void set_id(const synfig::String& x) { return id_entry.set_text(x); }
int common___::proc__(std::deque<Glib::ustring>* p,char*buf,long siz,char**addr_ret,void*shangji,void*ce) { const Glib::ustring& p0=(*p)[0]; if(p0=="剪贴板"){ if(siz==-1)return 1; Glib::RefPtr<Gtk::Clipboard> cb = Gtk::Clipboard::get(); if(p->size()>1) cb->set_text((*p)[1].c_str()); else *addr_ret=dup__(cb->wait_for_text().c_str()); return 1; } if(p0=="全屏"){ if(siz==-1)return 1; Gtk::Window* w=w__(p,1); if(!w) return 1; w->fullscreen(); return 1; } if(p0=="取消全屏"){ if(siz==-1)return 1; Gtk::Window* w=w__(p,1); if(!w) return 1; w->unfullscreen(); return 1; } if(p0=="置顶"){ if(siz==-1)return 1; Gtk::Window* w=w__(p,1); if(!w) return 1; w->set_keep_above(true); return 1; } if(p0=="取消置顶"){ if(siz==-1)return 1; Gtk::Window* w=w__(p,1); if(!w) return 1; w->set_keep_above(false); return 1; } if(p0=="无边框"){ if(siz==-1)return 1; Gtk::Window* w=w__(p,1); if(!w) return 1; w->set_decorated(false); return 1; } if(p0=="跳过任务栏"){ if(siz==-1)return 1; Gtk::Window* w=w__(p,1); if(!w) return 1; w->set_skip_taskbar_hint(true); return 1; } if(p0=="窗口活动"){ if(siz==-1)return 1; Gtk::Window* w=w__(p,1); if(!w) return 1; cpy__(buf,w->property_is_active(),siz); return 1; } if(p0=="图标"){ if(siz==-1)return 1; Gtk::Window* w=w__(p,2); if(!w) return 1; if(p->size()>1){ const Glib::ustring& p1=(*p)[1]; w->set_icon_name(p1); Glib::RefPtr<Gdk::Pixbuf> pb=Gdk::Pixbuf::create_from_file(p1); if(pb) w->set_icon(pb); }else cpy__(buf,w->get_icon_name().c_str(),siz); return 1; } if(p->size()<2){ return 0; } const Glib::ustring& p1=(*p)[1]; Gtk::Entry* e; Gtk::Label* l; Gtk::Button* b; Gtk::ToolButton* tb; Gtk::TextView* tv; Gtk::Notebook* n; Gtk::Bin* bI; Gtk::Widget* w; Gtk::Statusbar* sB; Gtk::FileChooserButton* fcb; Gtk::ToggleButton* tOb;//CheckButton RadioButton Gtk::ToggleToolButton*ttb; //Gtk::RadioButtonGroup* rbg; Gtk::MenuItem* mi; Gtk::CheckMenuItem* cmi; Gtk::SpinButton* sb; if(p0=="窗口标题"){ if(siz==-1)return 1; Gtk::Window* w1; if(p1=="") w1=sh_->main_win_; else{ sh_->builder_->get_widget(p1, w); if(!w){ d_(sh_,err_show_wufa_,2,p,1); return 1; } w1=(Gtk::Window*)w; } if(p->size()<3){ cpy__(buf,w1->get_title().c_str(),siz); }else{ w1->set_title((*p)[2]); } return 1; } if(p0=="内容"){ if(siz==-1)return 1; Glib::ustring text; bool read=false; int start=2; if(p->size()>2&&(*p)[2]=="读取"){ read=true; start=3; } for(size_t i=start;i<p->size();i++){ if((*p)[i]=="源码") text+=sh_->src_; else{ if(read){ string name=sh_->ui_file_; size_t i1=name.rfind('/'); if(i1==string::npos) i1=name.rfind('\\'); if(i1!=string::npos) name=name.substr(0,i1+1); name+=(*p)[i]; file_get__(name.c_str(),text); }else text+=(*p)[i]; } } if(p1=="源码"){ if(p->size()>2) sh_->src_=text; else *addr_ret=dup__(sh_->src_.c_str()); return 1; }else{ sh_->builder_->get_widget(p1, sb); if(sb){ if(p->size()>2){ float f=0; sscanf(text.c_str(),"%f",&f); sb->set_value(f); return 1; } } sh_->builder_->get_widget(p1, e); if(e){ if(p->size()<3){ *addr_ret=dup__(e->get_text().c_str()); }else{ e->set_text(text); } return 1; } sh_->builder_->get_widget(p1, l); if(l){ if(p->size()<3){ *addr_ret=dup__(l->get_text().c_str()); }else{ l->set_markup(text); } return 1; } sh_->builder_->get_widget(p1, tv); if(tv){ if(p->size()<3){ *addr_ret=dup__(tv->get_buffer()->get_text().c_str()); }else{ tv->get_buffer()->set_text(text); } return 1; } sh_->builder_->get_widget(p1, fcb); if(fcb){ if(p->size()<3){ *addr_ret=dup__(fcb->get_filename().c_str()); }else{ fcb->set_filename(text); /*GtkFileChooser *chooser=(GtkFileChooser *)fcb->gobj(); const gchar *filename=text.c_str(); gtk_file_chooser_unselect_all (chooser); //gtk_file_chooser_select_filename (chooser, filename); GFile *file; gboolean result; file = g_file_new_for_path (filename); result = gtk_file_chooser_select_file (chooser, file, NULL); //#define GTK_FILE_CHOOSER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_CHOOSER, GtkFileChooserIface)) //result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_file (chooser, file, NULL); g_object_unref (file);*/ } return 1; } sh_->builder_->get_widget(p1, tOb); if(tOb){ if(p->size()<3){ cpy__(buf,tOb->get_label().c_str(),siz); }else{ tOb->set_label(text); } return 1; } sh_->builder_->get_widget(p1, sB); if(sB){ if(p->size()<3){ }else{ sB->push(text,sB->get_context_id(text)); return 1; } } sh_->builder_->get_widget(p1, n); if(n){ if(p->size()<3){ cpy__(buf,n->get_current_page()+1,siz); }else{ n->set_current_page(s2i__(text,1)-1); } return 1; } } d_(sh_,err_show_wufa_,2,p,1); return 1; } if(p0=="勾选"){ if(siz==-1)return 1; if(p->size()>2){ bool b=d_(sh_,bool_,(*p)[p->size()-1].c_str()); for(size_t i=1;i<p->size()-1;i++){ sh_->builder_->get_widget((*p)[i], tOb); if(tOb){ tOb->set_active(b); continue; } sh_->builder_->get_widget((*p)[i], ttb); if(ttb){ ttb->set_active(b); continue; } sh_->builder_->get_widget((*p)[i], cmi); if(cmi){ cmi->set_active(b); continue; } d_(sh_,err_show_wufa_,2,p,i); return 1; } }else{ sh_->builder_->get_widget(p1, tOb); if(tOb){ cpy__(buf,tOb->get_active(),siz); return 1; } sh_->builder_->get_widget(p1, ttb); if(ttb){ cpy__(buf,ttb->get_active(),siz); return 1; } sh_->builder_->get_widget(p1, cmi); if(cmi){ cpy__(buf,cmi->get_active(),siz); return 1; } d_(sh_,err_show_wufa_,2,p,1); } return 1; } if(p0=="提示文字"){ if(siz==-1)return 1; sh_->builder_->get_widget(p1, w); if(w){ if(p->size()<3){ cpy__(buf,w->get_tooltip_markup().c_str(),siz); }else{ w->set_tooltip_markup((*p)[2]); } return 1; } d_(sh_,err_show_wufa_,2,p,1); return 1; } if(p0=="焦点"){ if(siz==-1)return 1; sh_->builder_->get_widget(p1, w); if(w){ w->grab_focus(); return 1; } d_(sh_,err_show_wufa_,2,p,1); return 1; } if(p0=="侦听"){ if(siz==-1)return 1; if(p->size()>2){ if(p1=="点击"){ Glib::ustring code; size_t size=p->size(); if(size>=4) code=(*p)[--size]; for(size_t i=2;i<size;i++){ if((*p)[i].length()==0) continue; Glib::SignalProxy0< void >* sp0=NULL; Glib::SignalProxy1< bool, GdkEventButton* >* sp1=NULL; Glib::ustring dong; bI=NULL; w=NULL; for(;;){ sh_->builder_->get_widget((*p)[i], b); if(b){ bI=b; w=b; dong=b->get_label(); sp0=&b->signal_clicked(); break; } sh_->builder_->get_widget((*p)[i], tb); if(tb){ bI=tb; w=tb; dong=tb->get_label(); sp0=&tb->signal_clicked(); break; } sh_->builder_->get_widget((*p)[i], mi); if(mi){ bI=mi; w=mi; sp1=&mi->signal_button_press_event(); break; } sh_->builder_->get_widget((*p)[i], w); if(w){ sp1=&w->signal_button_press_event(); break; } d_(sh_,err_show_wufa_,3,p,i,0); return 1; } if(w){ const char*arg4; if(dong.empty()){ dong=(*p)[i]; arg4=NULL; }else arg4=(*p)[i].c_str(); control___* c; const char*zhao; const char*arg3; //不buf会乱指 Glib::ustring buf3; if(w==mi){ zhao="菜单"; buf3=mi->get_label(); }else{ zhao=bI!=NULL?"按钮":p1.c_str(); buf3=w->get_tooltip_text(); } arg3=buf3.c_str(); if(!arg4) c=new control___(zhao,dong.c_str(),sh_,d_,code.c_str(),arg3); else c=new control___(zhao,dong.c_str(),sh_,d_,code.c_str(),arg3,arg4); if(sp0) sp0->connect(sigc::mem_fun(*c, &control___::on__)); else if(sp1) sp1->connect(sigc::mem_fun(*c, &control___::on1__)); w->set_data("ctl",c); if(p->size()==4) break; } } return 1; } d_(sh_,err_show_wufa_,2,p,1); return 1; } d_(sh_,err_show_buzu_,p); return 1; } if(p0=="点击"){ if(siz==-1)return 1; for(size_t i=1;i<p->size();i++){ w=NULL; for(;;){ sh_->builder_->get_widget((*p)[i], b); if(b){ w=b; break; } sh_->builder_->get_widget((*p)[i], tb); if(tb){ w=tb; break; } sh_->builder_->get_widget((*p)[i], mi); if(mi){ w=mi; break; } sh_->builder_->get_widget((*p)[i], w); if(w){ break; } d_(sh_,err_show_wufa_,3,p,i,0); return 1; } control___* c=(control___*)w->get_data("ctl"); if(!c){ d_(sh_,err_show_wufa_,3,p,i,0); return 1; } c->on__(); } return 1; } if(p0=="可见"){ if(siz==-1)return 1; sh_->builder_->get_widget(p1, w); if(w){ if(p->size()>2){ bool b=d_(sh_,bool_,(*p)[p->size()-1].c_str()); for(size_t i=1;i<p->size()-1;i++){ sh_->builder_->get_widget((*p)[i], w); if(w) w->set_visible(b); else d_(sh_,err_show_wufa_,2,p,i); } }else cpy__(buf,w->get_visible(),siz); return 1; } d_(sh_,err_show_wufa_,2,p,1); return 1; } if(p0=="可见状态"){ if(siz==-1)return 1; sh_->builder_->get_widget(p1, e); if(e){ bool b; if(p->size()>2) b=d_(sh_,bool_,(*p)[2].c_str()); else b=!e->get_visibility(); e->set_visibility(b); return 1; } d_(sh_,err_show_wufa_,2,p,1); return 1; } if(p0=="敏感"){ if(siz==-1)return 1; sh_->builder_->get_widget(p1, w); if(w){ if(p->size()>2){ bool b=d_(sh_,bool_,(*p)[p->size()-1].c_str()); for(size_t i=1;i<p->size()-1;i++){ sh_->builder_->get_widget((*p)[i], w); if(w) w->set_sensitive(b); else d_(sh_,err_show_wufa_,2,p,i); } }else cpy__(buf,w->get_sensitive(),siz); return 1; } d_(sh_,err_show_wufa_,2,p,1); return 1; } if(p0=="区域信息"){ if(siz==-1)return 1; sh_->builder_->get_widget(p1, w); if(w){ Gtk::Allocation a=w->get_allocation(); sprintf(buf,"%d,%d,%d,%d,",a.get_x(),a.get_y(),a.get_width(),a.get_height()); return 1; } d_(sh_,err_show_wufa_,2,p,1); return 1; } if(p0=="鼠标"){ if(siz==-1)return 1; sh_->builder_->get_widget(p1, w); if(w){ gint x,y; /*Glib::RefPtr<Gdk::Window> w2=w->get_window(); w2->get_pointer(x,y,);*/ w->get_pointer(x,y); sprintf(buf,"%d,%d,",x,y); return 1; } d_(sh_,err_show_wufa_,2,p,1); return 1; } if(p0=="数目"){ if(siz==-1)return 1; sh_->builder_->get_widget(p1, n); if(n){ sprintf(buf,"%d",n->get_n_pages()); return 1; } d_(sh_,err_show_wufa_,2,p,1); return 1; } if(p0=="遍历"){ if(siz==-1)return 1; const Glib::ustring& code=(*p)[p->size()-1]; bool exe=true; char s1[16]; const char*argv[]={s1}; int err; for(size_t i=1;i<p->size()-1&&exe;i++){ sh_->builder_->get_widget((*p)[i], n); if(n){ for(int pn=0;pn<n->get_n_pages();pn++){ w=n->get_nth_page(pn); sprintf(s1,"%d",pn+1); d_(sh_,call4_1_,code.c_str(),shangji,NULL,NULL,NULL,1,argv,0,ce,&err); if(err){ if(err==jieshiqi_go_+keyword_break_) break; if(err==jieshiqi_go_+keyword_continue_) continue; if(err==jieshiqi_go_+keyword_exit_){ exe=false; break; } d_(sh_,call4_2_,err); return 1; } } continue; } d_(sh_,err_show_wufa_,2,p,i); } return 1; } return 0; }
Widget_Preview::Widget_Preview(): Gtk::Table(1, 5), adj_time_scrub(0, 0, 1000, 0, 10, 0), scr_time_scrub(adj_time_scrub), b_loop(/*_("Loop")*/), current_surface(NULL), currentindex(-100000),//TODO get the value from canvas setting or preview option audiotime(0), adj_sound(0, 0, 4), l_lasttime("0s"), playing(false), jackdial(NULL), jack_enabled(false), jack_is_playing(false), jack_time(0), jack_offset(0) #ifdef WITH_JACK , jack_client(NULL), jack_synchronizing(false) #endif { //catch key press event for shortcut keys signal_key_press_event().connect(sigc::mem_fun(*this, &Widget_Preview::on_key_pressed)); //connect to expose events //signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Preview::redraw)); //manage all the change in values etc... //1st row: preview content preview_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); //pack preview content into scrolled window preview_window.add(draw_area); //preview window background color Gdk::Color bg_color; bg_color.set_red(54*256); bg_color.set_blue(59*256); bg_color.set_green(59*256); draw_area.modify_bg(Gtk::STATE_NORMAL, bg_color); adj_time_scrub.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_Preview::slider_move)); scr_time_scrub.signal_event().connect(sigc::mem_fun(*this,&Widget_Preview::scroll_move_event)); draw_area.signal_expose_event().connect(sigc::mem_fun(*this,&Widget_Preview::redraw)); scr_time_scrub.set_draw_value(0); disp_sound.set_time_adjustment(&adj_sound); timedisp = -1; //Set up signals to modify time value as it should be... disp_sound.signal_start_scrubbing().connect(sigc::mem_fun(*this,&Widget_Preview::scrub_updated)); disp_sound.signal_scrub().connect(sigc::mem_fun(*this,&Widget_Preview::scrub_updated)); Gtk::Button *button = 0; Gtk::Image *icon = 0; #if 1 //2nd row: prevframe play/pause nextframe loop | halt-render re-preview erase-all toolbar = Gtk::manage(new class Gtk::HBox(false, 0)); //prev rendered frame Gtk::Button *prev_framebutton; Gtk::Image *icon0 = manage(new Gtk::Image(Gtk::StockID("synfig-animate_seek_prev_frame"), Gtk::ICON_SIZE_BUTTON)); prev_framebutton = manage(new class Gtk::Button()); prev_framebutton->set_tooltip_text(_("Prev frame")); icon0->set_padding(0,0); icon0->show(); prev_framebutton->add(*icon0); prev_framebutton->set_relief(Gtk::RELIEF_NONE); prev_framebutton->show(); prev_framebutton->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this,&Widget_Preview::seek_frame), -1)); toolbar->pack_start(*prev_framebutton, Gtk::PACK_SHRINK, 0); { //play Gtk::Image *icon = manage(new Gtk::Image(Gtk::StockID("synfig-animate_play"), Gtk::ICON_SIZE_BUTTON)); play_button = manage(new class Gtk::Button()); play_button->set_tooltip_text(_("Play")); icon->set_padding(0,0); icon->show(); play_button->add(*icon); play_button->set_relief(Gtk::RELIEF_NONE); play_button->show(); play_button->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Preview::on_play_pause_pressed)); toolbar->pack_start(*play_button, Gtk::PACK_SHRINK, 0); } { //pause Gtk::Image *icon = manage(new Gtk::Image(Gtk::StockID("synfig-animate_pause"), Gtk::ICON_SIZE_BUTTON)); pause_button = manage(new class Gtk::Button()); pause_button->set_tooltip_text(_("Pause")); icon->set_padding(0,0); icon->show(); pause_button->add(*icon); pause_button->set_relief(Gtk::RELIEF_NONE); pause_button->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Preview::on_play_pause_pressed)); toolbar->pack_start(*pause_button, Gtk::PACK_SHRINK, 0); } //next rendered frame Gtk::Button *next_framebutton; Gtk::Image *icon2 = manage(new Gtk::Image(Gtk::StockID("synfig-animate_seek_next_frame"), Gtk::ICON_SIZE_BUTTON)); next_framebutton = manage(new class Gtk::Button()); next_framebutton->set_tooltip_text(_("Next frame")); icon2->set_padding(0,0); icon2->show(); next_framebutton->add(*icon2); next_framebutton->set_relief(Gtk::RELIEF_NONE); next_framebutton->show(); next_framebutton->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this,&Widget_Preview::seek_frame), 1)); toolbar->pack_start(*next_framebutton, Gtk::PACK_SHRINK, 0); //spacing Gtk::Alignment *space = Gtk::manage(new Gtk::Alignment()); space->set_size_request(8); toolbar->pack_start(*space, false, true); //loop button = &b_loop; IMAGIFY_BUTTON(button,"synfig-animate_loop", _("Loop")); toolbar->pack_start(b_loop, Gtk::PACK_SHRINK,0); //spacing Gtk::Alignment *space1 = Gtk::manage(new Gtk::Alignment()); space1->set_size_request(24); toolbar->pack_start(*space1, false, true); //halt render button = manage(new Gtk::Button(/*_("Halt Render")*/)); button->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Preview::stoprender)); IMAGIFY_BUTTON(button,Gtk::Stock::STOP, _("Halt render")); toolbar->pack_start(*button, Gtk::PACK_SHRINK, 0); //re-preview button = manage(new Gtk::Button(/*_("Re-Preview")*/)); button->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Preview::repreview)); IMAGIFY_BUTTON(button, Gtk::Stock::EDIT, _("Re-preview")); toolbar->pack_start(*button, Gtk::PACK_SHRINK, 0); //erase all button = manage(new Gtk::Button(/*_("Erase All")*/)); button->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Preview::eraseall)); IMAGIFY_BUTTON(button, Gtk::Stock::CLEAR, _("Erase all rendered frame(s)")); toolbar->pack_start(*button, Gtk::PACK_SHRINK, 0); //spacing Gtk::Alignment *space2 = Gtk::manage(new Gtk::Alignment()); space1->set_size_request(24); toolbar->pack_start(*space2, false, true); //jack jackdial = Gtk::manage(new JackDial()); #ifdef WITH_JACK jack_dispatcher.connect(sigc::mem_fun(*this, &Widget_Preview::on_jack_sync)); jackdial->signal_enable_jack().connect(sigc::mem_fun(*this, &studio::Widget_Preview::on_toggle_jack_pressed)); jackdial->signal_offset_changed().connect(sigc::mem_fun(*this, &studio::Widget_Preview::on_jack_offset_changed)); jackdial->signal_disable_jack().connect(sigc::mem_fun(*this, &studio::Widget_Preview::on_toggle_jack_pressed)); #endif //FIXME: Hardcoded FPS! jackdial->set_fps(24.f); jackdial->set_offset(jack_offset); if ( !getenv("SYNFIG_DISABLE_JACK") ) jackdial->show(); toolbar->pack_start(*jackdial, false, true); //zoom preview factor_refTreeModel = Gtk::ListStore::create(factors); zoom_preview.set_model(factor_refTreeModel); zoom_preview.property_has_frame() = true; zoom_preview.signal_changed().connect(sigc::mem_fun(*this, &Widget_Preview::preview_draw)); Gtk::TreeModel::Row row = *(factor_refTreeModel->append()); row[factors.factor_id] = "1"; row[factors.factor_value] = "25%"; row = *(factor_refTreeModel->append()); row[factors.factor_id] = "2"; row[factors.factor_value] = "50%"; row = *(factor_refTreeModel->append()); row[factors.factor_id] = "3"; row[factors.factor_value] = "100%"; row = *(factor_refTreeModel->append()); row[factors.factor_id] = "4"; row[factors.factor_value] = "200%"; row = *(factor_refTreeModel->append()); row[factors.factor_id] = "5"; row[factors.factor_value] = _("Fit"); zoom_preview.set_text_column(factors.factor_value); Gtk::Entry* entry = zoom_preview.get_entry(); entry->set_text("100%"); //default zoom level entry->set_icon_from_stock(Gtk::StockID("synfig-zoom")); entry->signal_activate().connect(sigc::mem_fun(*this, &Widget_Preview::on_zoom_entry_activated)); //set the zoom widget width zoom_preview.set_size_request(100, -1); zoom_preview.show(); toolbar->pack_end(zoom_preview, Gtk::PACK_SHRINK, 0); show_toolbar(); //3rd row: previewing frame numbering and rendered frame numbering Gtk::HBox *status = manage(new Gtk::HBox); status->pack_start(l_currenttime, Gtk::PACK_SHRINK, 5); Gtk::Label *separator = manage(new Gtk::Label(" / ")); status->pack_start(*separator, Gtk::PACK_SHRINK, 0); status->pack_start(l_lasttime, Gtk::PACK_SHRINK, 5); status->show_all(); //5th row: sound track disp_sound.set_size_request(-1,32); // attach all widgets attach(preview_window, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0); attach(scr_time_scrub, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); attach(*toolbar, 0, 1, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL); attach(*status, 0, 1, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); // attach(disp_sound,0,1,4,5,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK); preview_window.show_all(); scr_time_scrub.show_all(); //if(draw_area.get_window()) gc_area = Gdk::GC::create(draw_area.get_window()); #endif }
//shortcut keys TODO: customizable shortcut keys would be awesome. bool studio::Widget_Preview::on_key_pressed(GdkEventKey *ev) { //hide and show toolbar if (ev->keyval == gdk_keyval_from_name("h")) { if (toolbarisshown) hide_toolbar(); else show_toolbar(); return true; } //previous rendered frame if (ev->keyval == gdk_keyval_from_name("a")) { if(playing) pause(); seek_frame(-1); return true; } //play/pause if (ev->keyval == gdk_keyval_from_name("s")) { on_play_pause_pressed(); return true; } //next render frame if (ev->keyval == gdk_keyval_from_name("d")) { if(playing) pause(); seek_frame(+1); return true; } //loop if (ev->keyval == gdk_keyval_from_name("f")) { if(get_loop_flag()) set_loop_flag(false); else set_loop_flag(true); return true; } //zoom level switching //zoom to 25% Gtk::Entry* entry = zoom_preview.get_entry(); Glib::ustring text = entry->get_text(); if (ev->keyval == gdk_keyval_from_name("1")) { if(entry->get_text() != "25%") { entry->set_text("25%"); } return true; } if (ev->keyval == gdk_keyval_from_name("2")) { if(entry->get_text() != "50%") { entry->set_text("50%"); } return true; } if (ev->keyval == gdk_keyval_from_name("3")) { if(entry->get_text() != "100%") { entry->set_text("100%"); } return true; } if (ev->keyval == gdk_keyval_from_name("4")) { if(entry->get_text() != "200%") { entry->set_text("200%"); } return true; } if (ev->keyval == gdk_keyval_from_name("5")) { if(entry->get_text() != _("Fit")) { entry->set_text(_("Fit")); } return true; } return false; }
Window() : canvas(), checkbutton1("Plot 1"), checkbutton2("Plot 2"), checkbutton3("Plot 3"), label_x("X:"), label_y("Y:") { set_default_size(720, 580); Gdk::Geometry geometry; geometry.min_aspect = geometry.max_aspect = double(720)/double(580); set_geometry_hints(*this, geometry, Gdk::HINT_ASPECT); set_title("Gtkmm-PLplot test4"); canvas.set_hexpand(true); canvas.set_vexpand(true); canvas.set_background_color(Gdk::RGBA("Light Gray")); grid.set_column_homogeneous(true); checkbutton1.set_vexpand(false); checkbutton1.set_hexpand(false); checkbutton1.set_halign(Gtk::ALIGN_CENTER); checkbutton2.set_vexpand(false); checkbutton2.set_hexpand(false); checkbutton2.set_halign(Gtk::ALIGN_CENTER); checkbutton3.set_vexpand(false); checkbutton3.set_hexpand(false); checkbutton3.set_halign(Gtk::ALIGN_CENTER); std::valarray<double> x_va = Gtk::PLplot::indgen_va(1000)/50.0 - 10.0; std::valarray<double> y_va1 = sinh(x_va); std::valarray<double> y_va2 = cosh(x_va); std::valarray<double> y_va3 = tanh(x_va); //generate the data, the plot, add them to the canvas and use the return value to pass it to the checkbutton Gtk::PLplot::Plot2D *plot1 = Gtk::manage( new Gtk::PLplot::Plot2D( *Gtk::manage( new Gtk::PLplot::PlotData2D( x_va, y_va1, Gdk::RGBA("blue"), Gtk::PLplot::LineStyle::CONTINUOUS, 3.0 ) ), "X-axis", "Y-axis", "Hyperbolic sine", 0.5, 0.5, 0.0, 0.0 ) ); canvas.add_plot(*plot1); checkbutton1.connect_plot(plot1); Gtk::PLplot::Plot2D *plot2 = Gtk::manage( new Gtk::PLplot::Plot2D( *Gtk::manage( new Gtk::PLplot::PlotData2D( x_va, y_va2, Gdk::RGBA("red"), Gtk::PLplot::LineStyle::CONTINUOUS, 3.0 ) ), "X-axis", "Y-axis", "Hyperbolic cosine", 0.5, 0.5, 0.5, 0.0 ) ); canvas.add_plot(*plot2); checkbutton2.connect_plot(plot2); Gtk::PLplot::Plot2D *plot3 = Gtk::manage( new Gtk::PLplot::Plot2D( *Gtk::manage( new Gtk::PLplot::PlotData2D( x_va, y_va3, Gdk::RGBA("green"), Gtk::PLplot::LineStyle::CONTINUOUS, 3.0 ) ), "X-axis", "Y-axis", "Hyperbolic tangent", 0.4, 0.4, 0.2, 0.55 ) ); canvas.add_plot(*plot3); checkbutton3.connect_plot(plot3); checkbutton1.set_active(); checkbutton2.set_active(false); checkbutton3.set_active(); //let's make the first plot unpannable plot1->set_region_pannable(false); //let's override the background color of the second plot and hide it to make the surprise complete!! plot2->set_background_color(Gdk::RGBA("Yellow Green")); plot2->hide(); //also let's disable the region selection, for no reason whatsoever! plot2->set_region_selectable(false); //let's override the default region of this plot, this is NOT influenced by set_region_selectable()!!! plot2->set_region(-10, 10, -10, 10); //we can also change some other colors plot2->set_axes_color(Gdk::RGBA("Blue")); plot2->set_titles_color(Gdk::RGBA("Purple")); plot2->set_box_style(Gtk::PLplot::BOX_TICKS_TICK_LABELS_MAIN_AXES_MAJOR_MINOR_TICK_GRID); //lets'give the third plot a nice opaque background color plot3->set_background_color(Gdk::RGBA("White")); //but disable zooming by scrolling plot3->set_region_zoomable(false); //and give it an unusual selection box plot3->set_region_selection_color(Gdk::RGBA("Purple")); plot3->set_region_selection_width(4.0); //hook up signal_cursor_motion to the entries unsigned int plotnr = 0; while (1) { try { Gtk::PLplot::Plot2D *plot = dynamic_cast<Gtk::PLplot::Plot2D *>(canvas.get_plot(plotnr++)); plot->signal_cursor_motion().connect([this](double x, double y){ entry_x.set_text(Glib::Ascii::dtostr(x)); entry_y.set_text(Glib::Ascii::dtostr(y)); }); } catch (Gtk::PLplot::Exception &e) { break; } } grid.attach(checkbutton1, 0, 0, 1, 1); grid.attach(checkbutton2, 1, 0, 1, 1); grid.attach(checkbutton3, 2, 0, 1, 1); grid.attach(canvas, 0, 1, 3, 1); coordinates_grid.set_column_homogeneous(false); coordinates_grid.attach(label_x, 0, 0, 1, 1); coordinates_grid.attach(entry_x, 1, 0, 1, 1); coordinates_grid.attach(label_y, 2, 0, 1, 1); coordinates_grid.attach(entry_y, 3, 0, 1, 1); label_x.set_vexpand(false); label_x.set_hexpand(true); label_x.set_halign(Gtk::ALIGN_END); label_y.set_vexpand(false); label_y.set_hexpand(false); label_y.set_halign(Gtk::ALIGN_CENTER); entry_x.set_vexpand(false); entry_x.set_hexpand(false); entry_x.set_halign(Gtk::ALIGN_END); entry_y.set_vexpand(false); entry_y.set_hexpand(true); entry_y.set_halign(Gtk::ALIGN_START); coordinates_grid.set_column_spacing(5); grid.attach(coordinates_grid, 0, 2, 3, 1); grid.set_row_spacing(5); add(grid); set_border_width(10); grid.show_all(); }
void on_post_clicked() { ///To be executed when the posting form is submitted CURL *curl; FILE *fp; CURLcode res; string url_string = "https://sys.4chan.org"+BOARD+"post"; const char* url = url_string.c_str(); struct curl_httppost *formpost=NULL; struct curl_httppost *lastptr=NULL; struct curl_slist *headerlist=NULL; static const char buf[] = "Expect:"; curl_global_init(CURL_GLOBAL_ALL); Gtk::TextView *com_box = 0; builder->get_widget("textview1", com_box); string com = com_box->get_buffer()->get_text(); Gtk::Entry *captcha = 0; builder->get_widget("entry2", captcha); string captcha_text = captcha->get_text(); cout << com << endl; curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "com", CURLFORM_COPYCONTENTS, com.c_str(), CURLFORM_END); curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "recaptcha_response_field", CURLFORM_COPYCONTENTS, captcha_text.c_str(), CURLFORM_END); curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "recaptcha_challenge_field", CURLFORM_COPYCONTENTS, CHALLENGE.c_str(), CURLFORM_END); curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "pwd", CURLFORM_COPYCONTENTS, "999999", //Just a filler value. TODO CURLFORM_END); curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "MAX_FILE_SIZE", CURLFORM_COPYCONTENTS, "3145728", CURLFORM_END); curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "mode", CURLFORM_COPYCONTENTS, "regist", CURLFORM_END); if(THREAD != "") { //Only run if there is no current thread curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "resto", CURLFORM_COPYCONTENTS, THREAD.c_str(), CURLFORM_END); } Gtk::FileChooserButton *file = 0; builder->get_widget("filechooserbutton1", file); string file_name = file->get_filename(); if((file_name != "") && (THREAD != "")) { curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "upfile", CURLFORM_FILE, file_name.c_str(), CURLFORM_END); } curl = curl_easy_init(); headerlist = curl_slist_append(headerlist, buf); if (curl) { curl_easy_setopt(curl, CURLOPT_URL, url); char * fn = tmpnam(NULL); fp = fopen(fn,"wb"); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); res = curl_easy_perform(curl); /* always cleanup */ curl_easy_cleanup(curl); fclose(fp); /* then cleanup the formpost chain */ curl_formfree(formpost); /* free slist */ curl_slist_free_all (headerlist); std::ifstream t(fn); std::string str; t.seekg(0, std::ios::end); str.reserve(t.tellg()); t.seekg(0, std::ios::beg); string retval = str.assign((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>()); if(res != CURLE_OK) { fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); } else { cout << str << endl; boost::regex success("successful", boost::regex::icase); if(boost::regex_search(str, success)) { cout << "Clear all text boxes" << endl; com_box->get_buffer()->set_text(""); captcha->set_text(""); file->unselect_all(); Gtk::ToggleToolButton *post_but; builder->get_widget("toolbutton8", post_but); post_but->set_active(false); Gtk::ToolButton *ref_but; builder->get_widget("toolbutton6", ref_but); ref_but->signal_clicked(); notify_init ("Minichan"); NotifyNotification * Hello = notify_notification_new ("Post successful", "", "dialog-information"); notify_notification_show (Hello, NULL); } else { cout << "Post failed!" << endl; refresh_captcha(); notify_init ("Minichan"); NotifyNotification * Hello = notify_notification_new ("Post failed", "", "dialog-information"); notify_notification_show (Hello, NULL); } } } }
void set_id(const synfig::String& x) { return entry_id.set_text(x); }