static int addr_filter(struct nl_object *obj, struct nl_object *filter) { struct rtnl_addr *o = (struct rtnl_addr *) obj; struct rtnl_addr *f = (struct rtnl_addr *) filter; #define REQ(F) (f->a_mask & ADDR_ATTR_##F) #define AVAIL(F) (o->a_mask & ADDR_ATTR_##F) #define _O(F, EXPR) (REQ(F) && (!AVAIL(F) || (EXPR))) #define _C(F, N) (REQ(F) && (!AVAIL(F) || (o->N != f->N))) if (_C(IFINDEX, a_ifindex) || _C(FAMILY, a_family) || _C(SCOPE, a_scope) || _O(FLAGS, f->a_flags ^ (o->a_flags & f->a_flag_mask)) || _O(LABEL, strcmp(o->a_label, f->a_label)) || _O(PEER, nl_addr_cmp(o->a_peer, f->a_peer)) || _O(LOCAL, nl_addr_cmp(o->a_local, f->a_local)) || _O(ANYCAST, nl_addr_cmp(o->a_anycast, f->a_anycast)) || _O(MULTICAST, nl_addr_cmp(o->a_multicast, f->a_multicast)) || _O(BROADCAST, nl_addr_cmp(o->a_bcast, f->a_bcast))) return 0; #undef REQ #undef AVAIL #undef _O #undef _C return 1; }
void HookesLaw::compute_stress_imp( unsigned int dim, const libMesh::TensorValue<libMesh::Real>& g_contra, const libMesh::TensorValue<libMesh::Real>& g_cov, const libMesh::TensorValue<libMesh::Real>& /*G_contra*/, const libMesh::TensorValue<libMesh::Real>& G_cov, libMesh::TensorValue<libMesh::Real>& stress ) { stress.zero(); for( unsigned int i = 0; i < dim; i++ ) { for( unsigned int j = 0; j < dim; j++ ) { for( unsigned int k = 0; k < dim; k++ ) { for( unsigned int l = 0; l < dim; l++ ) { libMesh::Real strain_kl = 0.5*(G_cov(k,l) - g_cov(k,l)); _C(i,j,k,l) = _lambda*g_contra(i,j)*g_contra(k,l) + _mu*(g_contra(i,k)*g_contra(j,l) + g_contra(i,l)*g_contra(j,k)); stress(i,j) += _C(i,j,k,l)*strain_kl; } } } } return; }
double CXLinkOpenScorer::_CalProb(int N, int n, int n0, int l, int x, int x1) { if( l >= N ) return 0; if(n >= N) return 0; double lfTmpLogProb = 0 , lfLogProb = 0; lfTmpLogProb = _C(n0,x1); lfLogProb += lfTmpLogProb; lfTmpLogProb = _C(n - n0 ,x - x1); if(lfTmpLogProb < 0) return MINUS_INFINITE; lfLogProb += lfTmpLogProb; lfTmpLogProb = _C(N-n,l-x); if(lfTmpLogProb < 0) return MINUS_INFINITE; lfLogProb += lfTmpLogProb; lfTmpLogProb = _C(N,l); lfLogProb -= lfTmpLogProb; return lfLogProb; }
void CodeFormatter::AstyleFormat(const wxString& input, const wxString& options, wxString& output) { char* textOut = AStyleMain(_C(input), _C(options), ASErrorHandler, ASMemoryAlloc); if(textOut) { output = _U(textOut); output.Trim(); delete[] textOut; } }
void ParseThread::FindIncludedFiles(ParseRequest* req, std::set<std::string>* newSet) { wxArrayString searchPaths, excludePaths, filteredFileList; GetSearchPaths( searchPaths, excludePaths ); DEBUG_MESSAGE( wxString::Format(wxT("Initial workspace files count is %u"), (unsigned int)req->_workspaceFiles.size()) ) ; for(size_t i=0; i<req->_workspaceFiles.size(); i++) { wxString name(req->_workspaceFiles.at(i).c_str(), wxConvUTF8); wxFileName fn(name); fn.MakeAbsolute(); if(TagsManagerST::Get()->IsBinaryFile(fn.GetFullPath())) continue; filteredFileList.Add( fn.GetFullPath() ); } wxArrayString arrFiles; // Clear the results once { // Before using the 'crawlerScan' we lock it, since it is not mt-safe wxCriticalSectionLocker locker( TagsManagerST::Get()->m_crawlerLocker ); fcFileOpener::Instance()->ClearResults(); fcFileOpener::Instance()->ClearSearchPath(); for(size_t i=0; i<searchPaths.GetCount(); i++) { const wxCharBuffer path = _C(searchPaths.Item(i)); DEBUG_MESSAGE( wxString::Format(wxT("ParseThread: Using Search Path: %s "), searchPaths.Item(i).c_str()) ); fcFileOpener::Instance()->AddSearchPath(path.data()); } for(size_t i=0; i<excludePaths.GetCount(); i++) { const wxCharBuffer path = _C(excludePaths.Item(i)); DEBUG_MESSAGE( wxString::Format(wxT("ParseThread: Using Exclude Path: %s "), excludePaths.Item(i).c_str()) ); fcFileOpener::Instance()->AddExcludePath(path.data()); } for(size_t i=0; i<filteredFileList.GetCount(); i++) { const wxCharBuffer cfile = filteredFileList.Item(i).mb_str(wxConvUTF8); crawlerScan(cfile.data()); if( TestDestroy() ) { return; } } newSet->insert(fcFileOpener::Instance()->GetResults().begin(), fcFileOpener::Instance()->GetResults().end()); } }
/** Meant to set up an endpoing by name, but only checks for a valid name We don't bother trying to locate the endpoint here because the RPC logic already does that using much more specific information than just the name. */ afs_int32 smb_RPC_SetupEndpointByname(smb_rpc_t * rpcp, const clientchar_t * epnamep) { const char * secondary_name = NULL; if (!cm_ClientStrCmpI(epnamep, _C("wkssvc"))) { secondary_name = ".\\PIPE\\wkssvc"; } else if (!cm_ClientStrCmpI(epnamep, _C("srvsvc"))) { secondary_name = ".\\PIPE\\srvsvc"; } else { return CM_ERROR_NOSUCHPATH; } return MSRPC_InitConn(&rpcp->rpc_conn, secondary_name); }
void ToolPageLayer::setLayerCount(int layer, int selected) { XOJ_CHECK_TYPE(ToolPageLayer); this->inCbUpdate = true; int count = gtk_tree_model_iter_n_children(gtk_combo_box_get_model(GTK_COMBO_BOX(this->layerComboBox)), NULL); for (int i = count - 1; i >= 0; i--) { gtk_combo_box_remove_text(GTK_COMBO_BOX(this->layerComboBox), i); } gtk_combo_box_append_text(GTK_COMBO_BOX(this->layerComboBox), _C("Background")); for (int i = 1; i <= layer; i++) { string text = FS(_F("Layer {1}") % i); gtk_combo_box_prepend_text(GTK_COMBO_BOX(this->layerComboBox), text.c_str()); } setSelectedLayer(selected); this->layerCount = layer; this->inCbUpdate = false; }
void updateEnumActions(Menu &menu) { auto actions = menu.g(_L(EnumInfo<T>::typeKey()))->actions(); if (actions.size() > 2) { auto next = _C(menu).a("next"); if (next) next->setText(RootMenu::tr(QT_TRANSLATE_NOOP("RootMenu", "Select Next"))); } else { auto toggle = _C(menu).a("toggle"); if (toggle) toggle->setText(RootMenu::tr(QT_TRANSLATE_NOOP("RootMenu", "Toggle"))); } for (auto a : actions) { auto action = static_cast<EnumAction<T>*>(a); action->setText(EnumInfo<T>::description(action->enum_())); } }
void WINAPI GetPluginInfoW(struct PluginInfo *Info) { Info->StructSize = sizeof(PluginInfo); Info->Flags=0; static const wchar_t * PluginConfigMenuStrings[1], *PluginMenuStrings[1]; PluginConfigMenuStrings[0]=GetMsg(MConfTitle); Info->PluginConfig.Strings=PluginConfigMenuStrings; Info->PluginConfig.Count = 1; Info->PluginConfig.Guids = &MenuGuid; PluginMenuStrings[0]=GetMsg(MTitle); Info->PluginMenu.Strings=PluginMenuStrings; Info->PluginMenu.Count = 1; Info->PluginMenu.Guids = &MenuGuid; Info->CommandPrefix= _C(conf.Prefix); static const wchar_t * DiskMenuString[1]; DiskMenuString[0] = GetMsg(MTitle); if (conf.AddToDiskMenu) { Info->DiskMenu.Strings = DiskMenuString; Info->DiskMenu.Count = 1; Info->DiskMenu.Guids = &MenuGuid; } else { Info->DiskMenu.Strings = 0; Info->DiskMenu.Count = 0; Info->DiskMenu.Guids = 0; } }
bool Main_window::on_window_state_changed_callback(const GdkEventWindowState* state) { MLIB_D(_C( "Window state has been changed to %1 (%2).", state->new_window_state, state->changed_mask) ); if(state->changed_mask & GDK_WINDOW_STATE_ICONIFIED) { // Сохраняем текущее состояние окна this->gui->iconified = state->new_window_state & GDK_WINDOW_STATE_ICONIFIED; // Если окно свернули, то скрываем окно в трей, если этого требуют // настройки. При восстановлении окна всегда отображаем его - настройки // могли поменяться, пока оно было свернуто. if( !this->gui->iconified || ( get_client_settings().gui.show_tray_icon && get_client_settings().gui.minimize_to_tray ) ) this->set_visible_in_wm(!this->gui->iconified); if(!this->gui->iconified) this->update_gui(false); } return true; }
Renderable::Renderable(const std::vector<vec3> &_V, const std::vector<ivec3> &_T, const std::string& material) : mNumVertices(0), mNumElements(0), mNumIndicesPerElement(0), mVertexSize(0) { // generate buffers glGenBuffers(1, &mVbo); glGenBuffers(1, &mIbo); // init per vertex normal std::vector<vec3> _N; computeTriangleMeshNormals(_V,_T,_N); // init per vertex color std::vector<vec4> _C(0); // set per vertex st, binorm, tangent std::vector<vec2> _ST(0); std::vector<vec3> _binorm(0); std::vector<vec3> _tangent(0); // init transformation mat4 M; M.setIdentity(); initTriangleMesh(_V, _N, _C, _ST, _binorm, _tangent, _T, material, M); }
/* do a case-folding search of the star name mask with the name in namep. * Return 1 if we match, otherwise 0. */ int cm_MatchMask(clientchar_t *namep, clientchar_t *maskp, int flags) { clientchar_t *newmask, lastchar = _C('\0'); int i, j, casefold, retval; int star = 0, qmark = 0, dot = 0; /* make sure we only match 8.3 names, if requested */ if ((flags & CM_FLAG_8DOT3) && !cm_Is8Dot3(namep)) return 0; casefold = (flags & CM_FLAG_CASEFOLD) ? 1 : 0; /* optimize the pattern: * if there is a mixture of '?' and '*', * for example the sequence "*?*?*?*" * must be turned into the form "*" */ newmask = (clientchar_t *)malloc((cm_ClientStrLen(maskp)+2)*sizeof(clientchar_t)); for ( i=0, j=0, star=0, qmark=0; maskp[i]; i++) { lastchar = maskp[i]; switch ( maskp[i] ) { case '?': case '>': qmark++; break; case '<': case '*': star++; break; case '.': dot++; /* fallthrough */ default: if ( star ) { newmask[j++] = '*'; } else if ( qmark ) { while ( qmark-- ) newmask[j++] = '?'; } newmask[j++] = maskp[i]; star = 0; qmark = 0; } } if ( star ) { newmask[j++] = '*'; } else if ( qmark ) { while ( qmark-- ) newmask[j++] = '?'; } if (dot == 0 && lastchar == '<') newmask[j++] = '.'; newmask[j++] = '\0'; retval = szWildCardMatchFileName(newmask, namep, casefold) ? 1:0; free(newmask); return retval; }
/** @brief plugin initialization function, called by main program @param mode flags enumerating what sort of init to perform @return Plugin*, with refcount 1 if @a mode included runtime setup and that succeeded */ Plugin *init_plugin (E2PInit mode) { const gchar *aname2 = _("selmatchpart"); PLUGINIT_INTRO PLUGINIT_NUMBERED_ALLOCATE(2) PLUGINIT_NUMBERED_ACTION(1,_A(7),_("selmatch"),_e2p_select_same, _("_Select same"), _("Select items whose whole name matches a selected item in the other pane"), "plugin_"ANAME E2ICONTB) PLUGINIT_NUMBERED_ACTION(2,_A(7),aname2,_e2p_select_like, _("Select _like"), _("Select items whose name partially matches a selected item in the other pane"), NULL) //if the above included init, and it succeeded, more init needed if (iface.refcount == 1) { E2_OptionSetupExtra ex; gchar *group = g_strconcat(_C(34),".",_C(27),":",aname2,NULL); //_("plugins.options:selmatchpart" memset (&ex, 0, sizeof (E2_OptionSetupExtra)); ex.exbool = TRUE; E2_OptionSet *set = e2_plugins_option_register (E2_OPTION_TYPE_BOOL, "selmatch-start", group, _("match to first separator"), _("If enabled, name matching stops at the first instance of any specified separator, otherwise, at the last instance"), NULL, &ex, E2_OPTION_FLAG_FREEGROUP | E2_OPTION_FLAG_ADVANCED); //because plugins are loaded after config data, config options need to //get any data from unknown-options data e2_option_transient_value_get (set); ex.exstr = "."; set = e2_plugins_option_register (E2_OPTION_TYPE_STR, "selmatch-separators", group, _("separator character(s)"), _("String comprising all chars considered to be a 'separator'"), NULL, &ex, E2_OPTION_FLAG_ADVANCED); e2_option_transient_value_get (set); } PLUGINIT_NUMBERED_END }
std::map<std::string,std::string> TagsOptionsData::GetTokensMap() const { std::map<std::string,std::string> tokens; wxArrayString tokensArr = wxStringTokenize(m_tokens, wxT("\r\n"), wxTOKEN_STRTOK); for (size_t i=0; i<tokensArr.GetCount(); i++) { //const wxCharBuffer bufKey = _C( wxString item = tokensArr.Item(i).Trim().Trim(false); wxString k = item.BeforeFirst(wxT('=')); wxString v = item.AfterFirst(wxT('=')); const wxCharBuffer bufKey = _C(k); std::string key = bufKey.data(); std::string value; if (!v.empty()) { const wxCharBuffer bufValue = _C(v); value = bufValue.data(); } tokens[key] = value; } return tokens; }
std::map<std::string, std::string> TagsOptionsData::GetTokensMap() const { std::map<std::string, std::string> tokens; for(size_t i = 0; i < m_tokens.GetCount(); i++) { // const wxCharBuffer bufKey = _C( wxString item = m_tokens.Item(i); item.Trim().Trim(false); wxString k = item.BeforeFirst(wxT('=')); wxString v = item.AfterFirst(wxT('=')); const wxCharBuffer bufKey = _C(k); std::string key = bufKey.data(); std::string value; if(!v.empty()) { const wxCharBuffer bufValue = _C(v); value = bufValue.data(); } tokens[key] = value; } return tokens; }
void SelectBackgroundColorDialog::showColorchooser() { XOJ_CHECK_TYPE(SelectBackgroundColorDialog); this->colorDlg = gtk_color_selection_dialog_new(_C("Select color")); g_signal_connect(G_OBJECT (GTK_COLOR_SELECTION_DIALOG(this->colorDlg)->ok_button), "clicked", G_CALLBACK(&buttonSelectedCallback), this->colors.front()); // first entry gtk_dialog_run(GTK_DIALOG(this->colorDlg)); gtk_widget_destroy(this->colorDlg); this->colorDlg = NULL; }
void testcurl::OnGo( wxCommandEvent& event ) { if (texte_URL->IsEmpty()) wxMessageBox("URL vide", "Erreur", wxOK|wxICON_EXCLAMATION); else { texte_Resultat->SetValue(""); wxString url = texte_URL->GetValue(); curl_easy_setopt (curlhandle, CURLOPT_URL, _C(url)); printf ("url = %s\n", _C(url)); if (checkbox_Proxy->IsChecked()) { wxString proxy = texte_Proxy->GetValue(); curl_easy_setopt (curlhandle, CURLOPT_PROXY, _C(proxy)); curl_easy_setopt (curlhandle, CURLOPT_PROXYPORT, spin_Proxy->GetValue()); printf ("proxy = %s:%i\n", _C(proxy), spin_Proxy->GetValue()); } else curl_easy_setopt (curlhandle, CURLOPT_PROXY, ""); curldata.content = (char*) malloc(1); curldata.size = 0; if (curlhandle) curl_easy_perform(curlhandle); printf ("Content = %s", curldata.content); wxString content = wxString::From8BitData(curldata.content); texte_Resultat->SetValue(content); wxMessageBox("Fini !", "Fini !", wxOK); if (curldata.content) free (curldata.content); } }
GtkToolItem* ToolPageLayer::newItem() { XOJ_CHECK_TYPE(ToolPageLayer); GtkToolItem* it = gtk_tool_item_new(); GtkWidget* hbox = gtk_hbox_new(false, 1); gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(_C("Layer")), false, false, 7); gtk_box_pack_start(GTK_BOX(hbox), this->layerComboBox, false, false, 0); gtk_container_add(GTK_CONTAINER(it), hbox); return it; }
intptr_t WINAPI MakeDirectoryW(struct MakeDirectoryInfo *Info) { if(!Info->hPanel || INVALID_HANDLE_VALUE == Info->hPanel) return FALSE; fardroid * android = (fardroid *)Info->hPanel; static CString dest; dest = Info->Name; if (!android->CreateDir(dest, (int)Info->OpMode)) return FALSE; Info->Name = _C(dest); return TRUE; }
/** @brief (de)sensitize option tree buttons for selected option tree row Config dialog page buttons are de-sensitized if the row is the toolbar 'parent' @param selection pointer to selection @param model UNUSED @param path @param path_currently_selected UNUSED @param set data struct for the keybings option @return TRUE always (the row is always selectable) */ static gboolean _e2_bookmark_tree_selection_check_cb (GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, E2_OptionSet *set) { GtkTreeIter iter; if (gtk_tree_model_get_iter (set->ex.tree.model, &iter, path)) { gchar *label; gtk_tree_model_get (set->ex.tree.model, &iter, 0, &label, -1); gboolean result = strcmp (label, _C(41)); g_free (label); GtkTreeView *view = gtk_tree_selection_get_tree_view (selection); NEEDCLOSEBGL e2_option_tree_adjust_buttons (view, result); NEEDOPENBGL }
GtkToolItem* ToolPageSpinner::newItem() { XOJ_CHECK_TYPE(ToolPageSpinner); GtkToolItem* it = gtk_tool_item_new(); GtkWidget* hbox = gtk_hbox_new(false, 1); gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(_C("Page")), false, false, 7); gtk_box_pack_start(GTK_BOX(hbox), this->pageSpinner->getWidget(), false, false, 0); this->lbPageNo = gtk_label_new(""); gtk_box_pack_start(GTK_BOX(hbox), this->lbPageNo, false, false, 0); gtk_container_add(GTK_CONTAINER(it), hbox); return it; }
Renderable::Renderable(const std::vector<vec3>& _V, const std::vector<ivec3>& _T, const std::string& material, const mat4& M) : mNumVertices(0), mNumElements(0), mNumIndicesPerElement(0), mVertexSize(0) { // generate buffers glGenBuffers(1, &mVbo); glGenBuffers(1, &mIbo); std::vector<vec3> _N; computeTriangleMeshNormals(_V,_T,_N); std::vector<vec4> _C(0); std::vector<vec2> _ST(0); std::vector<vec3> _binorm(0); std::vector<vec3> _tangent(0); initTriangleMesh(_V, _N, _C, _ST, _binorm, _tangent, _T, material, M); }
bool clDynamicLibrary::Load(const wxString &name) { m_error.Clear(); #if defined (__WXMSW__) return m_lib.Load(name, wxDL_NOSHARE); #else // open the library //#if defined(__WXGTK__) && defined (ON_64_BIT) // // on GTK we need to pass RTLD_DEEPBIND otherwise symbols clashes // m_dllhandle = dlopen(_C(name), RTLD_LAZY| RTLD_LOCAL | RTLD_DEEPBIND); //#else m_dllhandle = dlopen(_C(name), RTLD_LAZY); //#endif if (!m_dllhandle) { m_error = wxString(dlerror(), wxConvUTF8); return false; } return true; #endif }
/** Setup a smb_fid:: structure for RPC \note Obtains fidp->mx */ afs_int32 smb_SetupRPCFid(smb_fid_t * fidp, const clientchar_t * _epnamep, unsigned short * file_type, unsigned short * device_state) { smb_rpc_t *rpcp; afs_int32 code = 0; const clientchar_t * epnamep; epnamep = cm_ClientStrChr(_epnamep, _C('\\')); if (epnamep == NULL) epnamep = _epnamep; else epnamep = cm_ClientCharNext(epnamep); lock_ObtainMutex(&fidp->mx); fidp->flags |= SMB_FID_RPC; fidp->scp = &cm_data.fakeSCache; cm_HoldSCache(fidp->scp); if (fidp->rpcp == NULL) { rpcp = malloc(sizeof(*rpcp)); memset(rpcp, 0, sizeof(*rpcp)); fidp->rpcp = rpcp; rpcp->fidp = fidp; } else { rpcp = fidp->rpcp; } code = smb_RPC_SetupEndpointByname(rpcp, epnamep); lock_ReleaseMutex(&fidp->mx); if (code == 0) { *file_type = SMB_FILETYPE_MESSAGE_MODE_PIPE; *device_state =((0xff) | /* instance count */ SMB_DEVICESTATE_READMSGFROMPIPE | SMB_DEVICESTATE_MESSAGEMODEPIPE | SMB_DEVICESTATE_PIPECLIENTEND); } return code; }
intptr_t WINAPI GetFilesW(struct GetFilesInfo *Info) { if(!Info->hPanel || INVALID_HANDLE_VALUE == Info->hPanel) return FALSE; fardroid * android = (fardroid *)Info->hPanel; static CString dest; dest = Info->DestPath; if (!android->GetFiles(Info->PanelItem, Info->ItemsNumber, dest, Info->Move, (int)Info->OpMode)) return FALSE; if (Info->Move) { //после удачного копирования удалим файлы Info->OpMode |= OPM_SILENT; if (!android->DeleteFiles(Info->PanelItem, Info->ItemsNumber, (int)Info->OpMode)) return FALSE; } Info->DestPath = _C(dest); return TRUE; }
void *clDynamicLibrary::GetSymbol(const wxString &name, bool *success) { m_error.Clear(); #if defined (__WXMSW__) bool rc; void *symb = m_lib.GetSymbol(name, &rc); *success = rc; return symb; #else dlerror(); // reset errors // load the symbol void *symb = dlsym(m_dllhandle, _C(name)); if(symb){ *success = true; }else{ *success = false; m_error = wxString(dlerror(), wxConvUTF8); } return symb; #endif }
int main(int argc, char *argv[]) { setbuf(stdout, NULL); setbuf(stderr, NULL); setlocale(LC_ALL, ""); char* domain = textdomain(PACKAGE_NAME); assert(domain != NULL); bind_textdomain_codeset(PACKAGE_NAME, "UTF-8"); textdomain(PACKAGE_NAME); gint update_rate = 100; gint cell_size = 4; gboolean print_version = FALSE; GOptionEntry cmd_options[] = { {"update-rate", 'u', 0, G_OPTION_ARG_INT, &update_rate, _C("Update rate in msec"), "100"}, {"cell_size", 'c', 0, G_OPTION_ARG_INT, &cell_size, _C("Cell size"), "8"}, {"version", 'v', 0, G_OPTION_ARG_NONE, &print_version, _C("Print version"), NULL}, {NULL} }; GError *error = NULL; GOptionContext *cmd_context = g_option_context_new(NULL); g_option_context_set_help_enabled(cmd_context, TRUE); g_option_context_add_main_entries(cmd_context, cmd_options, NULL); gchar **cmd_line = g_strdupv(argv); gint cmd_count = argc; if(g_option_context_parse(cmd_context, &cmd_count, &cmd_line, &error) == FALSE) { fprintf(stderr, _C("ERROR: %s\n\n"), error->message); g_error_free(error); } else { if(print_version == TRUE) { printf("game-life: %s\n", PACKAGE_VERSION); } else { gtk_init(&argc, &argv); GdkScreen* default_screen = gdk_screen_get_default(); gint screen_height = gdk_screen_get_height(default_screen); gint screen_width = gdk_screen_get_width(default_screen); size_t world_height = screen_height / (cell_size +1); size_t world_width = screen_width / (cell_size +1); game_universe_t* universe = NULL; game_init_universe(&universe, world_width, world_height, cell_size); game_set_random(universe); GtkWidget* main_wnd = gtk_window_new(GTK_WINDOW_TOPLEVEL); GdkWindow* root_wnd = gdk_screen_get_root_window(default_screen); gtk_widget_set_window(main_wnd, root_wnd); //gtk_window_fullscreen(GTK_WINDOW(main_wnd)); gtk_widget_set_app_paintable(main_wnd, TRUE); g_signal_connect(main_wnd, "destroy", G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(main_wnd, "event", G_CALLBACK(event_cb), NULL); g_signal_connect(main_wnd, "draw", G_CALLBACK(draw_cb), universe); const char* remote_wnd_env = getenv("XSCREENSAVER_WINDOW"); if(remote_wnd_env != NULL) // FIXME what is this shit? i dont know { char* end = NULL; Window remote_wnd = (Window)strtol(remote_wnd_env, &end, 0); GdkDisplay* default_display = gdk_display_get_default(); GdkWindow* window = gdk_x11_window_foreign_new_for_display(default_display, remote_wnd); //GtkStyle* main_wnd_style = gtk_widget_get_style(main_wnd); //gtk_style_set_background(main_wnd_style, window, GTK_STATE_NORMAL); gtk_widget_set_window(main_wnd, window); gtk_widget_set_realized(main_wnd, TRUE); gtk_window_resize(GTK_WINDOW(main_wnd), screen_width, screen_height); } gtk_widget_show_all(main_wnd); g_timeout_add(update_rate, update_image, main_wnd); gtk_main(); } } g_option_context_free(cmd_context); g_strfreev(cmd_line); return 0; }
// E <- 'd' ('a' 'b' | 'd') bool is_E(_iterator &it){ _head(2); if(_is('d') && _L(1) && _is('a') && _is('b') && _C(1) && _is('d') && _R){ return true; } return _false; }
// This example is equivalent to is_C: // D <- ('a' | '') 'b' bool is_D(_iterator &it){ _head(2); if(_L(1) && _is('a') && _C(1) && true && _R && _is('b')){ return true; } return _false; }
// The next example is // C <- 'a' 'b' | 'b' bool is_C(_iterator &it){ _head(1); if(_is('a') && _is('b') && _C(0) && _is('b')){ return true; } return _false; }